Use babel es6 to es5

Install

// Webpack accesses modules that Babel must depend on 
npm i - D babel - core babel - loader

// preset, which tells babel which syntax is used in the compiled files env contains the latest features in all current ECMAScript standards 
npm i - D babel - preset - env

// When compiling, the error says that if you are using loader6X to install 7 
npm i babel - loader @7 - D

// Promise is not converted by default, this plugin is required (reference at the beginning of the entry file after installation: require("@babel/polyfill");) 
npm install--save @babel / polyfill

Add in module.rules of webpack.config.js

{
    test: /\.js$/,
    exclude: /node_modules/,
    use: ['babel-loader']
}

Write in the .babelrc file
{
    "presets": [
        ["env"]
    ]

}

ps : ie only reaches 9 after compilation, ie does not support

Reprinted in: https://www.cnblogs.com/superjsman/p/11599155.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326559667&siteId=291194637