关于前端:微信小程序获取子组件数据中的data值和方法

4次阅读

共计 239 个字符,预计需要花费 1 分钟才能阅读完成。

子组件:

  data: {show: true,},

   checkFun() {this.show = false}

父组件:

 父组件应用子组件:<child id="child"></child>

// 获取子组件中的 data 值
const child= this.selectComponent('#child');
console.log(child.data.show);

// 调用子组件的办法
 useChildFun() {this.selectComponent('#child').checkFun();}
正文完
 0