vue多様な方法でstyleプロパティを制御
7553 ワード
2つの方法が使用されています.
1つ目:オブジェクト
2つ目:配列
コードを見てください:
1つ目:オブジェクト
2つ目:配列
コードを見てください:
doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue.js class title>
<script src="vue.js">script>
<script src="node_modules/axios/dist/axios.js">script>
<script src="node_modules/lodash/lodash.js">script>
head>
<body>
<div id="ask">
<h1 :style="{color:red,fontSize:size+'px'}"> h1>
<input type="text" v-model="size">
<h1 :style="style"> h1>
<h1 :style="[mykeji]"> h1>
div>
<script>
var app = new Vue({ // vue
el:'#ask',//vue id ask ,
data:{
red:'green',
size:16,
style:{
color:'blue',
fontSize:'200px'
},
mykeji:{
color:'red',
fontSize:'100px'
}
},
});
script>
body>
html>