當父組件引用了子組件的時候,會遇到父組件執行子組件的方法
父組件中的內容
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為方法需要的參數