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

时间:2020-03-27 14:58:50   收藏:0   阅读:90

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

父组件中的内容

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为方法需要的参数

原文:https://www.cnblogs.com/webzzc/p/12580926.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!