首页 > 编程 > JavaScript > 正文

vue toggle做一个点击切换class(实例讲解)

2019-11-19 14:10:42
字体:
来源:转载
供稿:网友

实例如下所示:

<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 toggle做一个点击切换class(实例讲解)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持武林网。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表