| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <!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>
- .box1{
- color: red;
- }
- .box2{
- color: blue;
- }
- .box3{
- font-size: 30px;
- }
- </style>
- </head>
- <body>
- <div id="app">
- <!-- v-bind: 可以将属性值解析成变量 -->
- <!-- 可以省略v-bind: 直接使用 : -->
- <!-- <div v-bind:class="className">hello world</div> -->
- <div :class="'active '+ className">hello world</div>
- <div v-bind:class="{'box1':isActive}">你好世界</div>
- <div v-bind:class="[className2,className]">你好世界</div>
- </div>
- <!-- v-bind 指令 功能类似于js中的setAttribute / getAttribute方法 可以向标签中动态绑定属性值 -->
- <script src="./js/vue.js"></script>
- <script>
- new Vue({
- el:"#app",
- data:{
- className:"box2",
- className2:"box3",
- isActive:false
- }
- })
- </script>
- </body>
- </html>
|