在小程序webview内嵌的h5页面中调用wx.chooseImage触发刷新页面?
在小程序webview内嵌的h5页面中调用wx.chooseImage拍照触发刷新页面,app.js以及当前页面的onshow里并没有逻辑代码,只有拍照有这个问题,相册没有。是什么原因啊
uploadImage() {
let that = this;
if (window.__wxjs_environment === "miniprogram") {
wx.miniProgram.getEnv(function (res) {
if (res.miniprogram) {
wx.chooseImage({
count: that.count,
success: function (req) {
that.totalUpload = false
that.syncUpload(req.localIds)
},
fail() {
Toast.fail("选择图片失败!");
},
});
}
});
}
},
syncUpload(localIds) {
const localId = localIds.pop();
const that = this
wx.uploadImage({
localId: localId, // 需要上传的图片的本地ID,由chooseImage接口获得
isShowProgressTips: 0,
success: function (resp) {
that.handleUpload2(resp.serverId)
if(localIds.length > 0){
that.syncUpload(localIds);
return
}else{
that.totalUpload = true
}
}
});
},
handleUpload(data){
Toast.loading({
message: '正在上传...',
forbidClick: true,
loadingType: 'spinner',
duration: 0
})
uploadWxFile({codeName:data}).then(response=>{
this.fileList.push({
id: response.fileMidId,
url: response.fileUrl,
})
this.$emit("change", this.fileList)
if(this.totalUpload){
Toast.clear()
}
}).catch(()=>{
if(this.totalUpload){
Toast.clear()
}
this.$toast.fail('上传失败!')
})
},