如果想在项目中使用ES6的
import
、export
、解构等,可以安装相关babel依赖
安装babel相关依赖
npm install babel-core babel-cli babel-plugin-transform-es2015-destructuring babel-plugin-transform-es2015-modules-commonjs babel-plugin-transform-es2015-parameters babel-plugin-transform-es2015-spread babel-plugin-transform-strict-mode -D
同时项目根目录下添加 .babelrc
文件,内容如下
{
"plugins": [
"transform-strict-mode",
"transform-es2015-modules-commonjs",
"transform-es2015-spread",
"transform-es2015-destructuring",
"transform-es2015-parameters"
]
}