微信小程序 子组件调用父组件方法

组件 js: 

var value = 123;
this.triggerEvent('callSomeFun', value)

父组件 wxml:

<component bind:callSomeFun="onLoad"></component>

父组件 js :

onLoad: function() {
  ... ...  
}




父组件调用子组件的方法

当父组件引用了子组件的时候,会遇到父组件执行子组件的方法

父组件中

wxml: <filter-cmp id='filter-cmp' bind:filterTriger='filterTriger'></filter-cmp>

js:    this.selectComponent('#filter-cmp').restFilterDatas();

子组件中: 定义方法 restFilterDatas








猜你喜欢

转载自www.cnblogs.com/shaozhu520/p/11781114.html