2020-03-13-vue
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>vue</title>
<style>
.pink{
background: pink;
}
.purple{
background: #f19de6;
}
#app>div{
width: 100px;
height: 100px;
}
</style>
</head>
<body>
<div id="app">
<div :class="[isTrue?'pink':'purple']" @click="clickChange()">
点击我切换颜色呀
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
var vm = new Vue({
el: '#app',
data: {
msg : '这是一条msg',
isTrue:false
},
methods: {
clickChange(){
this.isTrue = !this.isTrue
}
},
created(){
},
mounted(){
}
})
</script>
</body>
</html>