gpt4 book ai didi

ember.js - Ember >2.2.0 未定义获取 regeneratorRuntime

转载 作者:行者123 更新时间:2023-12-02 22:13:11 26 4
gpt4 key购买 nike

所以我正在使用 Ember 的服务内的迭代器。该代码使用旧样式脚本工作,我无法使用 ES2015 样式

ReferenceError: regeneratorRuntime is not defined

    stuff[Symbol.iterator] = function *(){
debugger;
let properties = Object.keys(this);
for(let p of properties){
yield this[p];
}
};

我知道这是因为函数上新的“*”运算符。我看过答案https://stackoverflow.com/a/28978619/24862描述了必须加载 browser-polyfill npm 但我有点不清楚如何让它在 ember 框架内工作。有人成功做到这一点吗?或者我应该放弃直到 Ember 支持它。

最佳答案

Polyfill

Babel comes with a polyfill that includes a custom regenerator runtime and core-js. Many transformations will work without it, but for full support you may need to include the polyfill in your app.

您现在应该包含为 ember-cli-babel 而不是 babel。像这样:

var app = new EmberApp(defaults, {
'ember-cli-babel': {
includePolyfill: true
}
}

再生器:

This package implements a fully-functional source transformation that takes the syntax for generators/yield from ECMAScript 2015 or ES2015 and Asynchronous Iteration proposal and spits out efficient JS-of-today (ES5) that behaves the same way.

来源:https://github.com/babel/ember-cli-babelhttps://github.com/facebook/regenerator

关于ember.js - Ember >2.2.0 未定义获取 regeneratorRuntime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34549838/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com