子組件向父組件傳數(shù)據(jù)
子組件:
<viewbindtap='ac'>{{checktag}}</view>
ac(){
console.log('hhhhhhh')
varmyEventDetail={
id:1
}//?detail對(duì)象吏夯,提供給事件監(jiān)聽函數(shù)
varmyEventOption={}//?觸發(fā)事件的選項(xiàng)
this.triggerEvent('myevent',myEventDetail,myEventOption)
}
父組件:
<tagselect checktag="{{checktag}}"tagshow="{{tagshow}}"class="tagops"bindmyevent="myevent"></tagselect>
myevent(e){
console.log(e)
}
父組件向子組件傳數(shù)據(jù)
子組件:
Component({
? properties: {
? ? checktag: {
? ? ? ?type: Array,
? ? ? ?value: [],
? ? ? ?observer: function(newVal, oldVal, changedPath) {
? ? ? ? ? ??newVal: 新設(shè)置的數(shù)據(jù),oldVal:?是舊數(shù)據(jù)即横,changedPath:指的是path
? ? ? ?}
? ? }
? }
})
父組件:
<tagselect checktag="{{checktag}}"tagshow="{{tagshow}}"class="tagops"bindmyevent="myevent"></tagselect>
data: {
? ? ?checktag: []
}