微信小程序 子给父传值
子给父传值
子组件 wxml
<view>
<text bindtap="addInfo">自给父传参</text>
</view>
子组件Js
methods: {
addInfo(){
let item = {
a:"3333"
}
this.triggerEvent('addInfo',item)
console.log("er")
}
}
子组件json
{
"component": true,
"usingComponents": {}
}
父组件 wxml
<tabs bind:addInfo="handleAdd"></tabs>
父组件Js
handleAdd(e){
console.log(e.detail)
},
父组件json 去声明子组件
"usingComponents": {
"tabs":"../../components/tabs/tabs"
}