查了好多教程,都是清一色的要装什么babel,我想说的是,在nodejs8以上已经原生支持es6语法书写代码了。
需要做如下两步:
- 把原来的
*.js
改为*.mjs
start-point.js
↓
start-point.mjs
- 需要增加node运行参数
--experimental-modules
//举个栗子
node.exe --experimental-modules path/to/start-point.mjs
查了好多教程,都是清一色的要装什么babel,我想说的是,在nodejs8以上已经原生支持es6语法书写代码了。
需要做如下两步:
*.js
改为*.mjs
start-point.js
↓
start-point.mjs
--experimental-modules
//举个栗子
node.exe --experimental-modules path/to/start-point.mjs
本文标题:在新版的nodejs下,直接使用es6语法的方法
本文链接:https://www.haomeiwen.com/subject/pzatxftx.html
网友评论