使用babel-preset-env,babel-polyfill库构建。
错误: 未处理的promise promise TypeError:方法Promise.prototype.then调用不兼容的接收函数(t){this._c = [],this._a = void 0,this._s = 0,this._d =!1,this._v = void 0,this._h = 0,this._n =!1}
getEvents: async function() {
const response = await fetch(
'/api/v1/event/'
{
credentials: 'same-origin'
}
);
// get Success
this.events = await response.json();
...
}
的package.json
"babel-polyfill": "^6.23.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-remove-strict-mode": "0.0.2",
"babel-preset-env": "^1.6.0",
"grunt-babel": "^6.0.0",
如果有人知道造成这种情况的原因,请回答。
我认为可能是一个承诺polyfill问题..因为
function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}
此函数来自promise polyfill ..
babel-polyfil模块中的stacktrace。
var $resolve = function (value) {
var promise = this;
var then;
if (promise._d) return;
promise._d = true;
promise = promise._w || promise; // unwrap
try {
if (promise === value) throw TypeError("Promise can't be resolved itself");
if (then = isThenable(value)) {
microtask(function () {
var wrapper = { _w: promise, _d: false }; // wrap
try {
错误发生在下一行
then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
} catch (e) {
$reject.call(wrapper, e);
}
});
} else {
promise._v = value;
promise._s = 1;
notify(promise, false);
}
} catch (e) {
$reject.call({ _w: promise, _d: false }, e); // wrap
}
};
抱歉,我无法重新生成错误..我记得它是在该行中触发的。