使用插件后微信小程序报错信息:
[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♪(・ω・)ノ (✪ω✪) ᕦ(・ㅂ・)ᕤ!!!