v-bind动态绑定class

对象语法

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .active{
            color: red;
        }
    </style>
</head>
<body>
<div id="app">
    <h2 class="title" :class="{active: isActive, line:isLine}">{{message}}</h2>
    <button @click="btnClick">按钮</button>
</div>

<script src="../js/vue.js"></script>
<script>
  const app = new Vue({
      el:‘#app‘,
      data:{
          message: ‘你好!‘,
          isActive: true,
          isLine: true
      },
      methods:{
          btnClick: function () {
              this.isActive = !this.isActive;
          }
      }
    })
</script>
</body>
</html>

  

v-bind动态绑定class

上一篇:vue+element 部署linux服务器


下一篇:centos7-docker搭建