微信小程序 selectComponent 获取自定义子组件
一、微信小程序中父组件获取子组件对象方法
1.selectComponent,返回选择器的第一个组件
2.selectAllComponents,返回选择器的组件列表
参数为选择器。
使用示例:
//根据ID获取组件对象
var showTwo = this.selectComponent('#myShow');
//访问属性,使用data访问内部属性和组件属性
console.info(showTwo.data);
//执行操作
showTwo.innerAdd();
//根据样式获取,建议使用selectAllComponents
var showThree = this.selectComponent('.myShow');
console.info(showThree.data);
showThree.innerAdd();