vue和react生命周期
react
componentWillMount(){ console.log('组件将要挂载','componentWillMount'); } componentDidMount(){ console.log('组件已经挂载','componentDidMount'); } componentWillReceiveProps(){ console.log('父组件传递的属性更新了', 'componentWillReceiveProps'); } shouldComponentUpdate(){ console.log('组件是否应该更新,需要返回布尔值', 'shouldComponentUpdate'); } componentWillUpdate(){ console.log('组件将要更新', 'componentWillUpdate'); } componentDidUpdate(){ console.log('组件已经更新', 'componentDidUpdate'); } componentWillUnmount(){ console.log('组件已经销毁', 'componentWillUnmount'); }
vue3.0
onMounted(() => {
console.log('子组件onMounted')
})
onBeforeMount(() => {
console.log('子组件onBeforeMount')
})
onBeforeUpdate(() => {
console.log('子组件onBeforeUpdate')
})
onUpdated(() => {
console.log('子组件onUpdated')
})
onBeforeUnmount(() => {
console.log('子组件onBeforeUnmount')
})
onUnmounted(() => {
console.log('子组件onUnmounted')
})
onErrorCaptured(() => {
console.log('子组件onErrorCaptured')
})
本文来自博客园,作者:zjxgdq,转载请注明原文链接:https://www.cnblogs.com/zjxzhj/p/16111751.html