Ember>2.2.0 getting regeneratorRuntime is not defined
Ember >2.2.0 getting regeneratorRuntime is not defined
所以我在 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];
}
};
我知道这是因为函数中新的“*”运算符。我看到的答案 描述了必须加载 browser-polyfill npm,但我有点不清楚如何让它在 ember 框架内工作。有没有人成功地做到了这一点?还是我应该放弃直到 Ember 支持它。
也许您对 Babel.js 的使用需要包含 polyfill,在您的 ember-cli-build.js 文件中使用:
var app = new EmberApp(defaults, {
// Add options here
babel: {
includePolyfill: true
}
});
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-babel and https://github.com/facebook/regenerator
所以我在 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];
}
};
我知道这是因为函数中新的“*”运算符。我看到的答案
也许您对 Babel.js 的使用需要包含 polyfill,在您的 ember-cli-build.js 文件中使用:
var app = new EmberApp(defaults, {
// Add options here
babel: {
includePolyfill: true
}
});
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-babel and https://github.com/facebook/regenerator