Sunny-117 opened this issue 2 years ago · 1 comments
/** * 本质就是then,只是少传了一个onFulfilled * 所以仅处理失败的场景 * @param {*} onRejected */ Promise.prototype.catch = function(onRejected) { return this.then(null, onRejected); }
Promise.prototype.catch = function (fn) { this.then(undefined, (err) => { fn(err); }); };