时间:2019-05-07 来源:小程序工厂
手机oneplus 5
系统安卓8.1.0
微信版本6.6.7
代码片段
wxml
sxcss:
.currentImgNumber{
font-size:24rpx;
position:absolute;
right:0;
bottom:-6px;
color: #b9b9b9;
}
.imgblock{
display: inline-block;
position: relative;
}
.deleteimg{
position: absolute;
right: -15rpx;
top:-15rpx;
font-size: 24rpx;
z-index: 1000;
width:46rpx;
height: 46rpx;
border: 0rpx solid #dcdddd!important;
}
js:
bindaddimg: function (e) { //添加图片
var imgs = this.data.srcarr;
var c = this.data.srcarr;
var that = this;
var nowCount = this.data.srclength - 1;
wx.chooseImage({
count: 5 - nowCount, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
var tempFilePaths = res.tempFilePaths;
for (var i = 0; i < tempFilePaths.length; i++) {
http.uploadFile('/miniApp/uploadImg', tempFilePaths[i],
function (data) {
var data = JSON.parse(data)
var imgs = that.data.srcarr;
var image = [data[0].url];
var c = image.concat(imgs);
if (image) {
that.data.currentImgNumber = that.data.currentImgNumber + 1;
}
var len = that.data.currentImgNumber;
that.setData({
currentImgNumber: len,
srcarr: c,
srclength: c.length,
selectImg: [],
imgIndex: { //选择要删除的图片的下标默认全是false
0: true,
1: true,
2: true,
3: true,
4: true
}
});
}, function (res) {
})
}
}
})
},
提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。