父子传值
父元素
js
data:{a:0}
html
<children id="{{a}}"></children>
子元素
js
properties:{
id: {type: Number,value: 0},//id就是传的值
}
子父传值
子元素
html
<view bindtap="input"></view>
js
input(){
this.triggerEvent('confirm', this.properties.id)
}
父元素
html
<children bindconfirm="haha"></children>
js
haha(e){
console.log(e.detail)//e.detail就是传的值
}