微信小程序 子给父传值

子给父传值

 子组件 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"
  }
 

     

       

  

posted @ 2020-09-09 13:30  会飞de佩奇  阅读(149)  评论(0)    收藏  举报