源码

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="vue.js"></script>

</head>
<body>
<div id="app">
<div
class="test"
v-bind:class="{active:isActive,green:isGreen}"
style="width: 200px; height: 200px;text-align: center;line-height: 200px">
hi vue
</div>
<div :style="{color:color,fontSize:size,background:isRed?'#ff0000':''}">
hi vue2
</div>
</div>
<script>
var vm = new Vue({
el: "#app",
data: {
isActive: true,
isGreen: true,
color: "#ffffff",
size: '50px',
isRed: true
}
});
</script>
<style>
.active {
background: #ff0000;
}

.test {
font-size: 30px;
}

.green {
color: chartreuse;
}
</style>
</body>
</html>

vue class 与style绑定 v-bind_javascript

 这个active的属性有没有生效取决于  


isActive 变量


修改为false的时候就不显示了

vue class 与style绑定 v-bind_javascript_02