vue动态切换class类
<div id="wrap" class="box"><div:class="{ red:isTrue}" @click="tago" class="blue">动态切换class类</div></di
·
<div id="wrap" class="box"> <div :class="{ red:isTrue}" @click="tago" class="blue">动态切换class类</div> </div> </template> <script> export default { name: "demo", data(){ return{ isTrue:true } }, methods:{ tago(){ this.isTrue = !this.isTrue; console.log(123) } } } </script> <style scoped> .blue{ width: 100px; height: 100px; background: blue; } .red{ width: 200px; height: 200px; background: red; } </style>
更多推荐
已为社区贡献33条内容
所有评论(0)