最佳答案
如何在 vue.js 中切换类?
我有以下条件:
<th class="initial " v-on="click: myFilter">
<span class="wkday">M</span>
</th>
new Vue({
el: '#my-container',
data: {},
methods: {
myFilter: function(){
// some code to filter users
}
}
});
当我点击 <th>
标签时,我想将 active
作为一个类应用,如下所示:
<th class="initial active" v-on="click: myFilter">
<span class="wkday">M</span>
</th>
这需要切换,也就是说,每次点击都需要添加/删除类。