使用插件后微信小程序报错信息:
[non-writable] modification of global variable “Promise.prototype.finally” is not allowed when using plugins at app.json.
解决,在封装请求的时候判断一下finally
// 无论promise对象最后状态如何都会执行
// Promise.prototype.finally = function(callback) {
// let P = this.constructor
// return this.then(
// (value) => P.resolve(callback()).then(() => value),
// (reason) =>
// P.resolve(callback()).then(() => {
// throw reason
// })
// )
// }
if (!Promise.prototype.finally) {
Promise.prototype.finally = function(callback) {
let P = this.constructor
return this.then(
(value) => P.resolve(callback()).then(() => value),
(reason) =>
P.resolve(callback()).then(() => {
throw reason
})
)
}
}
如果对您有所帮助,给个一键三连吧~~~Thanks♪(・ω・)ノ (✪ω✪) ᕦ(・ㅂ・)ᕤ!!!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。