绑定内联样式 :style
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./vue.js"></script>
<style>
.box{
width:100px;
height: 100px;
}
</style>
</head>
<body>
<div id="app">
<div style="background: red;color:green;">静态样式</div>
<hr>
<div :style="{background: 'red',color:'green'}">动态样式</div>
<div class="box" :style="styleN">动态样式变形</div>
<hr>
<ul>
<li v-for="(item,index) of arr" :style="{background:item.color}">
<p>{{item.name}}</p>
<p>{{item.url}}</p>
</li>
</ul>
</div>
<script>
new Vue({
el:'#app',
data:{
styleN:{
backgroundColor:'orange',
color:'green',
},
arr:[
{
name:'京东',
url:'http://www.jd.com',
color:'green'
},
{
name:'天猫',
url:'http://www.tmall.com',
color:'yellow'
},
]
},
methods:{
}
})
</script>
</body>
</html>