子组件向父组件传数据
子组件:
<viewbindtap='ac'>{{checktag}}</view>
ac(){
console.log('hhhhhhh')
varmyEventDetail={
id:1
}// detail对象,提供给事件监听函数
varmyEventOption={}// 触发事件的选项
this.triggerEvent('myevent',myEventDetail,myEventOption)
}
父组件:
<tagselect checktag="{{checktag}}"tagshow="{{tagshow}}"class="tagops"bindmyevent="myevent"></tagselect>
myevent(e){
console.log(e)
}
父组件向子组件传数据
子组件:
Component({
properties: {
checktag: {
type: Array,
value: [],
observer: function(newVal, oldVal, changedPath) {
newVal: 新设置的数据,oldVal: 是旧数据,changedPath:指的是path
}
}
}
})
父组件:
<tagselect checktag="{{checktag}}"tagshow="{{tagshow}}"class="tagops"bindmyevent="myevent"></tagselect>
data: {
checktag: []
}