最近在学习vue.js,感觉这是个很强大的web前端插件,由于业务需要,编编需要更改class,代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>class</title>
<script src="https://cdn.bootcss.com/vue/2.2.2/vue.min.js"></script>
<style>
.class1 {
background: #444;
color: red;
}
</style>
</head>
<body>
<div id="app">
<label for="r1">
修改颜色
<input type="checkbox" v-model="class1" id="r1">
</label>
<br/>
<div v-bind:class="{'class1': class1}">
directiva v-bind:class
</div>
</div>
</body>
<script>
new Vue({
el: '#app',
data: {
class1: true
}
});
</script>
</html>
交流讨论请添加微信号:17312678391