How to listen for 'props' changes

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

    for two way binding you have to use .sync modifier

    
    

    more details...

    and you have to use watch property in child component to listen and update any changes

    props: ['myprop'],
      watch: { 
        myprop: function(newVal, oldVal) { // watch it
          console.log('Prop changed: ', newVal, ' | was: ', oldVal)
        }
      }
    

提交回复
热议问题