1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <div id="app">
- {{count}}
- <button @click="add()">+1</button>
- <button @click="des()">销毁</button>
- </div>
- <script src="./vue.js"></script>
- <script>
- var app = new Vue({
- el: '#app',
- data: {
- count: 1
- },
- methods:{
- add(){
- this.count ++
- },
- des(){
- this.$destroy()
- }
- },
- //组件实例刚刚创建之前 属性计算之前
- beforeCreate() {
- console.log('beforeCreate', this.$data, this.$el)
- },
- //组件实例刚刚创建完成 属性绑定 dom未生成 el不存在
- created() {
- console.log('created',this.$data,this.$el)
- },
- //挂载之前
- beforeMount(){
- console.log('beforeMount',this.$data,this.$el)
- },
- //挂载之后
- mounted(){
- console.log('mounted',this.$data,this.$el)
- },
- //更新之前
- beforeUpdate(){
- console.log('beforeUpdate',this.$data,this.$el)
- },
- //更新之后
- updated(){
- console.log('updated',this.$data,this.$el)
- },
- //销毁之前
- beforeDestroy(){
- console.log('beforeDestroy',this.$data,this.$el)
- },
- destroyed(){
- console.log('destroyed',this.$data,this.$el)
- }
-
- })
- </script>
- </body>
- </html>
|