123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- /* h1 {
- color: red;
- } */
- .active {
- color: red;
- }
- .size {
- width: 300px;
- height: 300px;
- color: #0f0;
- background: #ff0;
- }
- .color {
- color: #00f;
- }
- </style>
- </head>
- <body>
- <!--
- 样式绑定
- 内置指令:v-bind 简写=> :
- class
- 格式:
- v-bind:class="样式语句"
- :class="样式语句"
- -->
- <div id="app">
- <h1 v-bind:class="{active:isShow}">这是第一行</h1>
- <!-- 样式不是覆盖是合并 -->
- <h2 :class="{active:isShow,size:true}">这是第一行</h2>
- <!-- 数组 + 对象 -->
- <h3 :class="[{color:true},'size']">新的语句</h3>
- </div>
- <script src="./vue.js"></script>
- <script>
- var app = new Vue({
- el:"#app",
- data:{
- isShow: true
- },
- })
- </script>
- </body>
- </html>
|