简体   繁体   English

如何将 ECMAScript 12 转换为 ECMAScript 10

[英]How to convert ECMAScript 12 to ECMAScript 10

我写了一个 JS 文件,其中的一些代码在 ECMAScript 12 中。问题是我所有的设备都只支持 ECMAScript 10。这是文件Javascript有没有可用的在线转换器,或者我如何手动完成?

You're looking for Babel .你正在寻找巴别塔

Babel will basically let you write modern JS code and then it can transpile it to "more primitive" code in order to run on a larger set of devices. Babel 基本上可以让您编写现代 JS 代码,然后它可以将其转换为“更原始”的代码,以便在更大的设备集上运行。

There are a bunch of options and a bunch of ways you can go about using it, but using the env preset and specifying your targets is probably a good place to start.有很多选项和很多方法可以使用它,但是使用env预设并指定您的targets可能是一个很好的起点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM