vue toggle做一个点击切换class(实例讲解)
时间:2021-05-30 08:45:51|栏目:vue|点击: 次
实例如下所示:
<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>
栏 目:vue
下一篇:使用vue-router在Vue页面之间传递数据的方法
本文标题:vue toggle做一个点击切换class(实例讲解)
本文地址:http://www.codeinn.net/misctech/131860.html






