Guest User

Untitled

a guest
Jan 7th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title></title>
  6. <script src="../Scripts/vue.min.js"></script>
  7. </head>
  8. <body>
  9. <div id="app">{{msg}}
  10. <button v-on:click="destroy_dom()">click</button>
  11. </div>
  12. <script>
  13. var app = new Vue({
  14. el: '#app',
  15. data: {
  16. msg:'hello world'
  17. },
  18. // init
  19. created: function() {
  20. alert('AAA');
  21. },
  22. //DOM 渲染完成
  23. mounted: function () {
  24. alert('BBB');
  25. },
  26. // 當data被修改
  27. updated: function () {
  28. this.msg = 'Lawrence';
  29. },
  30. // 當app被銷毀
  31. destroyed: function () {
  32. alert('destroyed');
  33. },
  34. methods: {
  35. destroy_dom: function () {
  36. //官方不建議使用.$destroy(),改用v-if 和 v-for 指令進行控制
  37. this.$destroy();
  38. }
  39. }
  40. })
  41. </script>
  42. </body>
  43. </html>
Add Comment
Please, Sign In to add comment