repeated-vms.html 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title></title>
  5. <meta charset="utf-8">
  6. <script src="../../../dist/vue.js"></script>
  7. </head>
  8. <body>
  9. <div class="item" v-repeat="items" v-component="item" v-component-id="items" v-on="click:click">
  10. {{msg + ' ' + title}}
  11. </div>
  12. <script>
  13. Vue.config({ debug: true })
  14. Vue.component('item', {
  15. ready: function () {
  16. this.title += ' init'
  17. },
  18. methods: {
  19. click: function () {
  20. this.title += ' click'
  21. }
  22. },
  23. data: {
  24. msg: 'msg'
  25. },
  26. computed: {
  27. reversed: function () {
  28. return this.title.split('').reverse().join('')
  29. }
  30. }
  31. })
  32. var app = new Vue({
  33. el: 'body',
  34. data: {
  35. items: [
  36. {title:'a'},
  37. {title:'b'},
  38. {title:'c'}
  39. ]
  40. }
  41. })
  42. </script>
  43. </body>
  44. </html>