10_v-bind.html 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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: white;
  16. font-size: 50px;
  17. }
  18. </style>
  19. </head>
  20. <body>
  21. <div id="app">
  22. <button @click="change">change</button>
  23. <!-- v-bind 动态绑定属性 -->
  24. <!-- <div v-bind:id="myName"></div> -->
  25. <div :id="myName"></div>
  26. <!-- <div :class="{aa:isA,bb:isB}">11111111111111</div> -->
  27. <!-- <div :class="[flag?class1:'',class2]"></div> -->
  28. <div style="width: 200px;height:300px"></div>
  29. <div :style="{color: color1}"></div>
  30. <div :style="[s1,s2]">xixixixixixiixiixxi</div>
  31. </div>
  32. <script src="./vue.js"></script>
  33. <script>
  34. var app = new Vue({
  35. el: '#app',
  36. data: {
  37. myName: 'zs',
  38. isA: true,
  39. isB: true,
  40. flag: false,
  41. class1: 'aa',
  42. class2: 'bb',
  43. color1: 'green',
  44. s1: {
  45. width: '200px',
  46. height: '300px'
  47. },
  48. s2:{
  49. background: 'red'
  50. }
  51. },
  52. methods: {
  53. change(){
  54. this.myName = 'lisi'
  55. }
  56. }
  57. })
  58. </script>
  59. </body>
  60. </html>