02-v-bind的动态绑定(对象语法)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>v-bind动态绑定(对象语法)</title>
<style>
.active {
color: red;
}
.line {
font-size: larger;
}
</style>
</head>
<body>
<div id="app">
<h2 :class="{active:isActive,line:isLine}">{{message}}</h2>
<button v-on:click="btnClick">按钮</button>
</div>
<script src="../js/vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
message: "你好啊",
isActive: true,
isLine: true
},
methods: {
btnClick: function () {
this.isActive = !this.isActive;
this.isLine = !this.isLine;
}
}
})
</script>
</body>
</html>