小程序上传图片 闪退咋回事?
我的小程序上传图片 就会出现闪退咋回事 以下是我的代码 //上传logo
uploadpic(){
var that=this;
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res){
//console.log(res);
if(res.tempFilePaths.length>0){
let imgUrl=res.tempFilePaths[0];
//console.log(imgUrl);
wx.showLoading({
title: '图片上传中',
});
that.uploadlogo(imgUrl)
}
}
})
},
uploadlogo(url){
let that=this;
let pics=that.data.pics;
wx.uploadFile({
filePath:url,
name:"pics",
url:app.globalData.url + '/api/upload/image',
formData: {
'filename': "pics"
},
header: {
"Content-Type": "multipart/form-data",
["Authori-zation"]: 'Bearer ' + app.globalData.token
},
success(res){
//console.log(res);
wx.hideLoading();
if(res.statusCode==200){
let data=JSON.parse(res.data);
console.log(data.data)
pics.push(data.data.url);
app.Tips({"title":data.msg});
that.setData({pics:pics})
}else{
app.Tips({title:res.data})
}
}
})
}