Foreword:
In the applet, listen to the data from the parent in the child component. Note that the arrow function cannot be used, and this error is undefined
Instructions:
1. The parent binds data to the child
<message-list
data="{
{messageList}}"
/>
2. The child receives data
Component({
//父级的字段
properties: {
data:Array,
}
})
3. Children listen to data through observers
Note: Arrow functions cannot be used, and an error will be reported
observers: {
'data': function (val) {
if(val.length>0){
this.handleDataFun(val)
}
},
}