component.html 963 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <div id="test">
  2. <!-- v-component + v-with -->
  3. <div id="component-and-with" v-component="avatar" v-with="user"></div>
  4. <!-- custom element + v-with -->
  5. <avatar id="element-and-with" v-with="user"></avatar>
  6. <!-- v-with alone -->
  7. <div id="with" v-with="user">{{hi}} {{name}}</div>
  8. <!-- v-component alone -->
  9. <div id="component" v-component="simple"></div>
  10. <!-- custom element alone -->
  11. <simple id="element"></simple>
  12. </div>
  13. <script src="../../../dist/vue.js"></script>
  14. <script>
  15. Vue.config({debug: true})
  16. Vue.component('avatar', {
  17. template: '{{hi}} {{name}}',
  18. ready: function () {
  19. console.log(JSON.stringify(this))
  20. }
  21. })
  22. Vue.component('simple', {
  23. template: '{{hi}} {{user.name}}'
  24. })
  25. var app = new Vue({
  26. el: '#test',
  27. data: {
  28. hi: '123',
  29. user: {
  30. name: 'Jack'
  31. }
  32. }
  33. })
  34. </script>