Babel支持Object.entries [英] Babel support for Object.entries
问题描述
我正在查看第3阶段的Object.values / Object.entries 我真的很想在我当前的JavaScript项目中使用它。
I'm looking at the stage 3 proposal of Object.values/Object.entries and I'd really like to use it in my current JavaScript project.
但是,我无法弄清楚是否有支持它的Babel预设。由于上面链接的GitHub存储库说它是第3阶段提案,我认为它将是babel-preset-stage-3的一部分,但似乎不是。
However, I can't figure out whether there's any Babel preset which supports it. Since the GitHub repository linked above says it's a stage 3 proposal, I assumed it would be part of babel-preset-stage-3, but it seems not.
是否存在任何让我今天使用Object.entries的Babel预设(甚至是插件?)?
Is there any Babel preset (or even plugin?) that lets me use Object.entries today?
推荐答案
使用 babel ,安装
- babel-preset-es2017
- babel-plugin-transform-runtime
支持 Object.values
/ Object.entries
以及其他 ES2017 功能。
gives support for Object.values
/Object.entries
as well as other ES2017 functionality.
根据模块的建议,使用以下命令配置 .babelrc :
As per recommendation by the modules, configure .babelrc with the following:
{
"plugins": ["transform-runtime"],
"presets": ["es2017"]
}
这篇关于Babel支持Object.entries的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!