绑定class的三种方法:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./reset.css">
<style>
.green{
width: 200px;
margin: 20px auto;
height: 200px;
background-color: chartreuse;
}
.red{
color: crimson;
}
.green1{
width: 200px;
margin: 20px auto;
height: 200px;
background-color: chartreuse;
}
.red1{
color: crimson;
}
.test1{
width: 200px;
margin: 20px auto;
height: 200px;
background-color: chartreuse;
}
.red2{
color: crimson;
}
</style>
</head>
<body>
<div id="app">
<div :class="arr">泡泡1</div>
<div :class="{green1:true,red1:true}">泡泡2</div>
<div :class="['green2','red2',{test1:true}]"> 泡泡3</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
const app1 = new Vue({
el:'#app',
data:{
arr:['green','red']
},
methods:{
}
})
</script>
</body>
</html>