Vue子组件如何实时接收父组件传递过来的属性

在子组件中使用watch监听props中那个父组件传递过来的属性,注意:如果是对象,而非普通的属性例如info:'xxxx',则需要使用以下写法(但是又测试了一遍,发现不用写deep:true也可以,有点懵=。=):

props: {

info: Object

},

watch: {

info: {

handler (curVal, oldVal) {

this.onScroll(curVal) // 做点什么

},

deep: true

}

},

猜你喜欢

转载自blog.csdn.net/hzxOnlineOk/article/details/85330262