一、子传父
1、子组件自定义事件名
<view class="withdraw" bindtap="getInputnumber">提现记录</view>
js
methods: {
getInputnumber:function(e){
this.triggerEvent('myEvent',e.detail.value) //这里的myEvent是自己自定义的事件名字,需要父组件中通过他来接受,
}
}
2、父组件通过事件名获取
<hello bind:myEvent="OnViewText"></hello>
js
OnViewText(){
console.log(1111)
}
二、父传子
1、在子组件json中声明自己为组件
{
"component": true,
"usingComponents": {}
}
2、在父组件中定义组件
{
"navigationStyle":"custom",
"usingComponents": {
"header": "/components/header-xx"
}
}
3、父组件wxml定义一个text="{ {parentPatam}}"
<hea