在新版的nodejs下,直接使用es6语法的方法

查了好多教程,都是清一色的要装什么babel,我想说的是,在nodejs8以上已经原生支持es6语法书写代码了。
需要做如下两步:

  1. 把原来的 *.js改为*.mjs
start-point.js
      ↓
start-point.mjs
  1. 需要增加node运行参数
--experimental-modules

//举个栗子
node.exe --experimental-modules path/to/start-point.mjs

你可能感兴趣的:(在新版的nodejs下,直接使用es6语法的方法)