uniapp 小程序 下载图片,开发版本可以,体验版本失败: 报错信息:fail url not in domain list
代码内容如下:
downLoadPic(){
let that=this;
uni.downloadFile({
url: that.pics,
success: (res) => {
var tempFilePath = res.tempFilePath; // 这里拿到后端返回的图片路径
uni.saveImageToPhotosAlbum({
filePath: tempFilePath,
success: function (data) {
},
fail: function (err) {
if (err.errMsg === “saveImageToPhotosAlbum:fail:auth denied” || err.errMsg === “saveImageToPhotosAlbum:fail auth deny” || err.errMsg === “saveImageToPhotosAlbum:fail authorize no response”) {
// 这边微信做过调整,必须要在按钮中触发,因此需要在弹框回调中进行调用
uni.showModal({
title: ‘提示’,
content: ‘需要您授权保存相册’,
showCancel: false,
success: modalSuccess => {
uni.openSetting({
success(settingdata) {
if (settingdata.authSetting[‘scope.writePhotosAlbum’]) {
uni.showModal({
title: ‘提示’,
content: ‘获取权限成功,再次点击图片即可保存’,
showCancel: false,
})
} else {
uni.showModal({
title: ‘提示’,
content: ‘获取权限失败,将无法保存到相册哦~’,
showCancel: false,
})
}
},
fail(failData) {
console.log(“failData”, failData)
},
complete(finishData) {
console.log(“finishData”, finishData)
}
})
}
})
}
},
complete(res) {
// wx.hideLoading()
}
})
} ,
fail: (res) => {
that.errrorFla=res.errMsg
}
});
}
解决方法是:
服务器域名下面的 downloadFile合法域名
添加合法域名