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


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

父組件
<component bind:callSomeFun="onLoad"></component>

   =========================
<!-- 當自定義組件觸發“myevent”事件時,調用“onMyEvent”方法 --> <component-tag-name bindmyevent="onMyEvent" /> <!-- 或者可以寫成 --> <component-tag-name bind:myevent="onMyEvent" /> 
Page({ onMyEvent: function(e){ e.detail // 自定義組件觸發事件時提供的detail對象 } }) 

 

 

轉自:https://www.jianshu.com/p/635d9647d4ff 


免責聲明!

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



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