Vue .babelrc配置

在VUE开发过程当中。须要使用babel来说ES6及其以上的语法转化成能够被是识别的语法。所以须要使用:babel-loader.react

babel-loader7.x 须要使用的插件 以及.babelrc 文件中的内容npm

npm i -D babel-core babel-loader babel-plugin-transform-runtime
npm i -D babel-preset-env babel-preset-stage-0
{
  "presets": ["env", "stage-0"],
  "plugins": [
    "transform-runtime"
  ]
}

babel-loader8.x 须要使用的插件。以及.bablerc文件中的内容json

npm i @babel/core babel-loader @babel/plugin-transform-runtime @babel/plugin-proposal-object-rest-spread -D
npm i @babel/preset-react @babel/preset-env babel-preset-mobx -D
npm i @babel/runtime -S
{
  "presets": ["@babel/preset-react", "@babel/preset-env", "babel-preset-mobx"],
  "plugins": [
    "@babel/plugin-transform-runtime",
    "@babel/plugin-proposal-object-rest-spread",
    "transform-remove-strict-mode" // 去除严格约束时使用
  ]
}
// babelrc为json文件不能够有注

报错:babel

"use strict" 使用插件 babel-plugin-transform-remove-strict-mode  以后在.babelrc中加上spa

'@babel/core' 就是babel-loader和babel-core的版本不匹配。插件

相关文章
相关标签/搜索