假设子组件中写有方法getData()
// 返回数据
getData() {
let flag = this.onStartValidate();
if (!flag) return false
let { form } = this.data;
return form;
},
在父组件中的json文件中注册子组件,
在父组件中的wxml文件中引入子组件,并定义id
<sh-batch id="shBatch" form="{{ sendForm }}"></sh-batch>
最后在负组件中的js文件中调用selectComponent()方法就可以直接调用子组件中的方法
let form = this.selectComponent("#shBatch").getData();