vuejs点击class变化

来源:互联网 发布:linux snmp配置 编辑:程序博客网 时间:2024/06/05 11:56
<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <title>Vue.js小demo</title>  <style> .static{  width: 100px;  height: 60px;  margin:30px auto;  display: inline-block;  cursor: pointer; } .class-a{    background: lightpink; } .class-b{    background: #eee; }  </style></head><body> <div id="content">    <span class="static" v-bind:class="{'class-a':isA,'class-b':!isA}" @click="toggle"></span></div></body><script src="https://cdn.bootcss.com/vue/2.2.6/vue.js"></script><script>var vm=new Vue({    el:"#content",    data:function(){        return {            isA:false        };    },    methods:{        toggle:function(){            this.isA=!this.isA;        }    }});</script></html>

0 0
原创粉丝点击