父页面
page.wxml
<subPage value="{{value}}"></subPage>
组件js
properties:{
value:{
type:String,
value:'默认值',
observer:'updata'//子组件监听父组件值得变化函数名,类似于vue 的watch
}
}
methods:{
updata(newVal) {
console.log('实时更新的数据'+newVal)
}
}
父页面
page.wxml
<subPage value="{{value}}"></subPage>
组件js
properties:{
value:{
type:String,
value:'默认值',
observer:'updata'//子组件监听父组件值得变化函数名,类似于vue 的watch
}
}
methods:{
updata(newVal) {
console.log('实时更新的数据'+newVal)
}
}