vue中class用法

<!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>Document</title>
    <style>
        .active{
            color: red;
        }
        .active2{
            background: yellow;
        }
    </style>
</head>
<body>
    <!--mvvm里面的v-->
    <div id="app">
        <div :class="{active:color,active2:bgco}">
            你好
        </div>
    </div>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script >
        //这是mvvm里面的vm
        var vm=new Vue({
            el:'#app',
           //这是mvvm里面的m 
            data:{
                color:true,
                bgco:true
               
            }
        })
    </script>

</body>
</html>

猜你喜欢

转载自www.cnblogs.com/antyhouse/p/9069534.html