小程序在父组件调用子组件的方法


当父组件引用了子组件的时候,会遇到父组件执行子组件的方法

父组件中的内容

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