vue toggle做一个点击切换class
<template>
<div>
<span :class="{'bg-primary text-danger':isA,'bg-success text-white':!isA}" @click="toggle()">AAAAA</span>
</div>
</template>
<script>
export default {
name: 'hello',
data () {
return {
isA: false
}
},
methods:{
toggle:function () {
this.isA=!this.isA
}
}
}
</script>
<style scoped>
@import "../../../src/assets/plugin/bootstrap-4.0.0-alpha.6-dist/css/bootstrap.css";
</style>
来源:CSDN
作者:longzhoufeng
链接:https://blog.csdn.net/longzhoufeng/article/details/69952063