1.创建和注册组件就不说了下面直接使用子组件
<setpicker id="butt" shows="{{array}}"></setpicker>
2. 在子组件js里面properties对应父组件传递的参数---子组件
properties: {
'shows':{
type:Array,
value:''
}
},
3.在组件生命周期把父组件传递的参数给子组件赋值---子组件
ready(){
this.setData({
array:this.properties.shows,
})
}
4.父组件获取子组件的参数--父组件js里面使用selectComponent获取对应id的组件---父组件
click(){
let myButton = this.selectComponent("#butt")
console.log(myButton.data.app)//data.app是我随便通过子组件改变的一个参数
},
5.调用父组件方法
<pop id="pop" bind:aaa="aaa"></pop>//bind父组件方法
this.triggerEvent('')//子组件调用
网友评论