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')
    })

  

posted @ 2022-04-07 13:04  zjxgdq  阅读(25)  评论(0编辑  收藏  举报