How to listen for 'props' changes

前端 未结 13 1544
无人及你
无人及你 2020-11-30 17:27

In the VueJs 2.0 docs I can\'t find any hooks that would listen on props changes.

Does VueJs have such hooks like onPropsUpdated() or simi

13条回答
  •  眼角桃花
    2020-11-30 18:10

    You can use the watch mode to detect changes:

    Do everything at atomic level. So first check if watch method itself is getting called or not by consoling something inside. Once it has been established that watch is getting called, smash it out with your business logic.

    watch: { 
      myProp: function() {
       console.log('Prop changed')
      }
    }
    

提交回复
热议问题