<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>使用object与array控制class</title>
    <script src="vue.js"></script>
</head>
<body>
<style>
    .green{color: green}
    .color{
        color: red;
    }
    .font{font-size: 50px;}
</style>
<div >
    <h1 :class="lt">
        科技中国
    </h1>
    <hr>
    <h1 class="green" :class="{color:false}">
        科技中国
    </h1>
    <hr>
    <h2 :class="['color','font']">www.baidu.com</h2>
    <hr>
    <h2 :class="[success,font]">www.baidu.com</h2>
</div>
<script>
    var app = new Vue({
        el: '#lantian',
        data: {
            lt:{color:true,font:true},
            success:'color',
            font:'font'
        }
    });
</script>
</body>
</html>

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
  • 2022-12-23
  • 2021-09-23
  • 2021-11-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
相关资源
相似解决方案