微信小程序 子組件調用父組件方法


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









免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM