如下所示:
<!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="/UploadFiles/2021-04-02/vue.js">以上这篇vuejs点击class变化的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。