vue生命周期

 

一、vue的生命周期是什么

    vue每个组件都是独立的,每个组件都有一个属于它的生命周期,从一个组件创建、数据初始化、挂载、更新、销毁,这就是一个组件所谓的生命周期。

在组件中具体的方法有:

  beforeCreate

    created

    beforeMount

    mounted

    beforeUpdate

    updated

    beforeDestroy

    destroyed



作者:CalvinXie
链接:https://www.jianshu.com/p/410b6099be69
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

二、vue生命周期的在项目中的执行顺序

data () {

    return {

    rendered: false,

}

}

...

1.beforeCeate(){

    console.log(this.rendered);    // undefined  

 

}

2.created() {

    console.log(this.$el);//undefined

    console.log(this.rendered);  // false

}

 

3.beforeMount() {

    console.log(this.$el);//undefined

}

 

 

4.mounted() {

    console.log(this.$el);

}

 

 

5.beforeDestroy(){

    console.log(this.$el);

    console.log(this.rendered); 

}

 

 

6.destroyed() {

    console.log(this.$el);

    console.log(this.rendered);

}

三、vue中内置的方法 属性和vue生命周期的运行顺序(methods、computed、data、watch、props)

props => methods =>data => computed => watch;

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值