1,安装babel-polyfill(低版本不支持es6)
cnpm install --save-dev babel-polyfill
2,打开webpack.base.conf.js引入它 require(‘babel-polyfill’)
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
const webpack = require("webpack");
require('babel-polyfill')
这里面也引入
entry: {
app: './src/main.js',
'babel-polyfill': 'babel-polyfill',
},
3, mian.js中引入它(有时会报错如果在entry中引入的话mian中不引入)
import 'babel-polyfill'
4,如果有vuex也引入(有时会报错如果在entry中引入的话vuex中不引入)
import 'babel-polyfill'