How to listen for 'props' changes

前端 未结 13 1567
无人及你
无人及你 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:09

    Have you tried this ?

    watch: {
      myProp: {
        // the callback will be called immediately after the start of the observation
        immediate: true, 
        handler (val, oldVal) {
          // do your stuff
        }
      }
    }
    

    https://vuejs.org/v2/api/#watch

提交回复
热议问题