transition.html 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <style type="text/css">
  2. .test {
  3. width: 600px;
  4. height: 100px;
  5. background-color: #f00;
  6. padding: 10px;
  7. border: 1px solid #000;
  8. overflow: hidden;
  9. transition: all .2s ease;
  10. -moz-transition: all .2s ease;
  11. -webkit-transition: all .2s ease;
  12. }
  13. .v-enter, .v-leave {
  14. height: 0;
  15. padding-top: 0;
  16. padding-bottom: 0;
  17. border-top-width: 0;
  18. border-bottom-width: 0;
  19. }
  20. .v-enter {
  21. background-color: #00f;
  22. }
  23. .v-leave {
  24. background-color: #0f0;
  25. }
  26. ul {
  27. padding: 0;
  28. }
  29. </style>
  30. <div id="test">
  31. <div>
  32. <button class="button-0" v-on="click:set">0</button>
  33. <button class="button-1" v-on="click:set">1</button>
  34. <button class="button-2" v-on="click:set">2</button>
  35. <button class="push" v-on="click:push">push</button>
  36. <button class="pop" v-on="click:pop">pop</button>
  37. <button class="splice" v-on="click:splice">splice</button>
  38. </div>
  39. <ul>
  40. <li
  41. class="test"
  42. v-repeat="items"
  43. v-show="filter(this)"
  44. v-transition
  45. v-attr="data-id:a">
  46. {{a}}
  47. </li>
  48. </ul>
  49. <div class="test if" v-transition v-if="items.length > 1">This is only visible when item.length > 1</div>
  50. </div>
  51. <h1 style="margin:0">123</h1>
  52. <script src="../../../dist/vue.js"></script>
  53. <script>
  54. var test = new Vue({
  55. el: '#test',
  56. data: {
  57. b: 1,
  58. set: function (e) {
  59. this.b = +e.target.textContent
  60. },
  61. push: function () {
  62. this.items.push({a: this.items.length + 1 })
  63. },
  64. pop: function () {
  65. this.items.pop()
  66. },
  67. splice: function () {
  68. this.items.splice(0, 1, {a:99})
  69. },
  70. filter: function (item) {
  71. return item.a > this.b
  72. },
  73. items: [
  74. {
  75. a: 1
  76. },
  77. {
  78. a: 2
  79. }
  80. ]
  81. }
  82. })
  83. </script>