当前位置:首页 > 微信 > 正文

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

11-25 微信

标签:on()   code   call   trigger   bind   rda   执行   component   微信   

组件 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








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

标签:on()   code   call   trigger   bind   rda   执行   component   微信   

温馨提示: 本文由杰米博客推荐,转载请保留链接: https://www.jmwww.net/weixin/15651.html

博客主人杰米WWW
杰米博客,为大家提供seo以及it方面技巧喜欢的朋友收藏哦!
  • 11365文章总数
  • 2266821访问次数
  • 建站天数
  • 头条文章

    图文推荐

    站长推荐

    友情链接