3_v-bind.html 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. .aa{
  10. width: 200px;
  11. height: 200px;
  12. background: red;
  13. }
  14. .bb{
  15. color: blue;
  16. font-size: 50px;
  17. }
  18. .cc{
  19. color:green
  20. }
  21. </style>
  22. </head>
  23. <body>
  24. <div id="app">
  25. <button @click="change()">click</button>
  26. <!-- v-bind 动态绑定属性 -->
  27. <!-- <div v-bind:id="name"></div> -->
  28. <div :id="name"></div>
  29. <!-- <div class="aa bb">aaaaa</div> -->
  30. <!-- <div :class="{aa:isA,bb:isB}">aaaaaa</div> -->
  31. <!-- <div :class="[class1,class2]">2222222222222222</div> -->
  32. <!-- <div :class="[flag?class2:class3]">3333333</div> -->
  33. <!-- <div style="width:200px;height:200px"></div>
  34. <div :style="{color: color1}"></div> -->
  35. <div :style="[s1,s2]"></div>
  36. </div>
  37. <script src="vue.js"></script>
  38. <script>
  39. new Vue({
  40. el:"#app",
  41. data:{
  42. name:"zs",
  43. class1: 'aa',
  44. class2: 'bb',
  45. class3: 'cc',
  46. isA: true,
  47. isB: true,
  48. flag:false,
  49. color:'green',
  50. s1:{
  51. width:'100px',
  52. height:'100px'
  53. },
  54. s2:{
  55. background:'red'
  56. }
  57. },
  58. methods:{
  59. change(){
  60. this.name = 'lisi'
  61. // this.class2 = 'cc'
  62. }
  63. }
  64. })
  65. </script>
  66. </body>
  67. </html>