image.png

代码

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue.js 样式-class 属性绑定单个样式</title>
    <script src="//static.gzj2001.com/vue/vue.js"></script>
    <style>
    .box{
    background-color: #666;
    width: 250px;
    height: 250px;
    border: 1px solid red;
    margin: 10px;
    }
    </style>
</head>
<body>
    <div id="app">
        <div class="box">000</div>
        <div v-bind:class="{box:choose}">111</div>
        <div v-bind:class="mycss">222</div>
    </div>
    <script>
        new Vue({
            el:"#app",
            data:{
                choose:true,
                nochoose:false,
                mycss:"box"
            }
        })
    </script>
</body>
</html>

效果

image.png