Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <title></title>
- <script src="../Scripts/vue.min.js"></script>
- </head>
- <body>
- <div id="app">{{msg}}
- <button v-on:click="destroy_dom()">click</button>
- </div>
- <script>
- var app = new Vue({
- el: '#app',
- data: {
- msg:'hello world'
- },
- // init
- created: function() {
- alert('AAA');
- },
- //DOM 渲染完成
- mounted: function () {
- alert('BBB');
- },
- // 當data被修改
- updated: function () {
- this.msg = 'Lawrence';
- },
- // 當app被銷毀
- destroyed: function () {
- alert('destroyed');
- },
- methods: {
- destroy_dom: function () {
- //官方不建議使用.$destroy(),改用v-if 和 v-for 指令進行控制
- this.$destroy();
- }
- }
- })
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment