<view class="weui-cell"> <view class="weui-cell__bd"> <view class="weui-uploader"> <view class="weui-uploader__hd"> <view class="weui-uploader__title">当前设备照片</view> <view class="weui-uploader__info">{{current.length}}/3</view> </view> <view class="weui-uploader__bd"> <view class="weui-uploader__files" id="uploaderFiles"> <block wx:for="{{current}}" wx:key="*this"> <view class="weui-uploader__file" bindlongpress="currentDelImg" data-index="{{index}}"> <image class="weui-uploader__img" src="{{item}}" id="{{item}}" bindtap="currentPreviewImage" mode="aspectFill" /> </view> </block> </view> <view class="weui-uploader__input-box" wx:if="{{current.length < 3}}"> <view class="weui-uploader__input" bindtap="currentChooseImage"></view> </view> </view> </view> </view> </view>
/ * Remove image * / currentDelImg: function (E) { var that = the this ; var Current = that.data.current; var index = e.currentTarget.dataset.index; // get the current picture press subscript wx.showModal ({ title: 'prompt' , Content: 'you sure you want to delete this picture?' , Success: function (RES) { IF (res.confirm) { console.log ( 'click determined' ); current.splice (index , 1); } The else IF (res.cancel) { the console.log ( 'click the Cancel' ); return to false ; } that.setData ({ Current }); } }) }
Reproduced in: https: //www.cnblogs.com/zjj1990/p/11065012.html