• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

//vue2.x

导出默认值{

data () {

返回{}

},

方法: {

.

},

beforeCreate() {},

已创建(){},

beforeMount() {},

已安装(){},

beforeUpdate() {}

已更新(){},

beforeDestroy() {},

已销毁(){}

}

//vue3.x

导入{

在出发前,

在安装时,

onBeforeUpdate,

未更新,

onBeforeUnmount,

未安装的

}来自“vue”

导出默认值{

setup() {

onBeforeMount(()={

控制台。日志(“安装前的组件”)

})

onMounted(()={

console.log("组件已安装")

})

onBeforeUpdate(()={

console.log('组件是onBeforeUpdate’)

})

未更新(()={

console.log("组件未更新")

})

onBeforeUnmount(()={

console.log('组件在onBeforeUnmount上)

})

未安装(()={

console.log("组件未安装")

})

}

}

2.x中生命周期钩子放在跟方法同级属性下

3.x中需要先导入钩子,然后在设置方法中注册钩子回调,并且钩子命名也跟反应保持一样了

3.x移除了2.x中的创建前和创造钩子,通过设置方法代替

1ynropzcys03216.png

2.x中,vue模板只允许有一个根节点

3.x中,vue模板支持多个根节点,用过反应的人应该知道做出反应。碎片和/

转:https://juejin.cn/post/6867123074148335624

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now