vue 的生命周期 -尊龙游戏旗舰厅官网
文章目录
- 7——12
- 1:计数器
- 1:直接操作
- 2:使用函数
- 2:mvvm
- 3:options选项
- 4:生命周期
- 5:vue的生命周期函数
1:计数器
1:直接操作
<h2> 当前计数: {{counter}}h2> <button v-on:click="counter "> button> <button v-on:click="counter--">-button>2:使用函数
<button v-on:click="add"> button> <button v-on:click="sub">-button>const app = new vue({el:"#app",data:{counter:0},methods:{add:function(){console.log("add焙执行");this.counter ;},sub:function(){console.log(“sub被执行”);this.counter--;}})2:mvvm
3:options选项
-
内容
- el
- data
- methods
-
什么时候叫函数,什么时候叫方法
- 方法:method 在类里面的
- 函数:function 是独立出来的,例如js中独立的 函数是一等公民
-
四个钩子
- created
- mounted
- updated
- destroyed
4:生命周期
-
如果开发完成 是tags的版本d
-
debug版本 和release 版本
-
告诉我你自己在什么阶段了,比如在特定的时间段发送请求,进行回调。created,mounted,updated,destroyed
-
从创建到销毁的整个过程
5:vue的生命周期函数
- callhook
- 生命周期函数,也叫钩子函数
- 绿色的部分,是自己内部做的
- 更新dom
- vue 实例一般是不会销毁的,但是组件是会销毁的