html部分

view class="img-box"    view class="img" wx:for="{{imgs}}" wx:for-item="item" wx:key="*this"        image src="{{item}}" data-index="{{index}}" mode="aspectFill" bindtap="previewImg"/image        view class="delete-btn" data-index="{{index}}" catchtap="deleteImg"删除/view    /view    view class="upload-img-btn" bindtap="chooseImg" wx:if="{{imgs.length9}}"上传/view/view.img-box{    width: 100%;    height: 100%;    display: flex;    flex-direction: row;    flex-wrap: wrap}.img{    width: 100px;    height: 100px;       position: relative;}.img image{    width: 100%;    height: 100%;}.delete-btn{    position: absolute;    bottom: 0;    left: 0;    width: 100%;    height: 30px;    font-size: 12px;    color: #fff;    background: rgba(0,0,0,.5);    text-align: center;    line-height: 30px;}.upload-img-btn{    width: 100px;    height: 100px;    text-align: center;    line-height: 100px;    border: 1px solid #ccc;}

js部分

// pages/upImg/upimg.jsPage({    data: {        imgs: []    },    onLoad: function (options) {    },    chooseImg(){        let that = this;        let len = this.data.imgs;        if(len=9){            this.setData({                lenMore: 1            })                       return;        }        wx.chooseImage({            success: (res)={                let tempFilePaths = res.tempFilePaths;                console.log(tempFilePaths)                let imgs = that.data.imgs;                for(let i=0;itempFilePaths.length;i++){                    if(imgs.length9){                        imgs.push(tempFilePaths[i])                    }else{                        that.setData({                            imgs                        })                        wx.showModal({                            title: '提示',                            content: '最多只能有九张图片'                        })                        return;                    }                }                that.setData({                    imgs                })            }        })    },    previewImg(e){        let index = e.currentTarget.dataset.index;        let imgs = this.data.imgs;        wx.previewImage({            current: imgs[index],            urls: imgs,        })    },    deleteImg(e){        let _index = e.currentTarget.dataset.index;        let imgs = this.data.imgs;        imgs.splice(_index,1);        this.setData({            imgs        })    }})

 

TAG标签: 微信小程序怎么删除朋友圈分组

http://www.xiaochengxub.com/read-104648.html