关于vue的生命周期

顺序

	 //1、初始化阶段
	  beforeCreate () {
	       console.log("beforeCreate()");
	   },
	   created () {
	       console.log("created()");
	   },
	   beforeMount () {
	       console.log("beroreMount()");
	   },
	   mounted () { //初始化之后立即调用,发送ajax请求,启动定时器等异步操作
	        console.log("mounted()");
	   },
	   //2、更新阶段
	   beforeUpdate () {
	       console.log("beforeUpdate()");
	   },
	   updated () {
	       console.log("updated()");
	   },
	   //3、死亡阶段
	   beforeDestroy () { //做一些收尾工作,比方说清除计时器
	       console.log("beforeDestroy()");
	       clearInterval(this.intervalId);
	   },
	   destroyed () {
	       console.log("destroyed()")
	   },

猜你喜欢

转载自blog.csdn.net/qq_36939013/article/details/90703929