选择主题

选择导航背景

webpack+element-ui兼容性问题

1 npm install --save-dev babel-loader babel-core

2 在webpack.config.js中设置

module: {

   rules: [

     {

       test: /\.js$/,

       loader: "babel-loader",

       include: [

         resolve("src"),

         resolve("test"),

       ],

     },Ï

   ]

}


3 npm install babel-preset-env --save-dev

4 在.babelrc文件中

{

"presets":["evn"]

}

    [

      "env",

      {

        "modules": false,

        "targets": {

          "browsers": ["> 1%", "last 2 versions"]

        }

      }

      "stage-2"

    ],

5 npm install --save babel-polyfill

require("babel-polyfill")或import("babel-polyfill")

通过webpack.config.js,在入口处添加:

module.exports = { entry: ["babel-polyfill", "./app/js"] };

为了不污染全局对象和内置的对象原型,可以用babel-plugin-transform-runtime,在.babelrc文件中

"plugins": [

    [

      "transform-runtime",

      {

        "helpers": false,

        "polyfill": true,

        "moduleName": "babel-runtime"

      }

    ],

  ]