<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://unpkg.com/vue/dist/vue.js"></script>
</head>
<style type="text/css">
.active {
color: red;
}
</style>
<body>
<div id="app">
<p v-bind:class="{active: isActive}">{{ message }}</p>
<button type="button" v-on:click="onClick">点我</button>
</div>
<script>
const app = new Vue({
el: '#app',
data: {
message: 'Hello Vue.js!',
isActive: true
},
methods: {
onClick: function() {
this.isActive = !this.isActive;
}
}
})
</script>
</body>
</html>

