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


當父組件引用了子組件的時候,會遇到父組件執行子組件的方法

父組件中的內容

wxml: 

<view wx:for="{{imgs}}" wx:key="index" style="width: 500rpx;height: 300rpx;margin: 30rpx auto;">
  <button bindtap="ondelete" style="" data-index="{{index}}">刪除</button>
  <image src="{{item.url}}" style="width: 100%;height: 100%;"></image>
</view>

<xly-upload id='btn' customeStyle="true"  bindsuccess="uploadChange"binddelete="deleteChange" bindfail="uploadfail">
<text>上傳</text>
</xly-upload>

js:   

ondelete(e) {
this.selectComponent('#btn').DelImg(e);
},

在父組件中調用子組件的刪除方法DelImg,e為方法需要的參數


免責聲明!

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



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