IE兼容Vue项目

一、今天遇到了vue项目在IE11下显示空白的地方,第一个反应是兼容性,然后仔细检查了一下项目,然后发现没有去安 装babel-polyfill,所以就第一时间去安装:

npm install babel-polyfill -D
    然后在main.js里引入(一般放在首行):
import 'babel-polyfill'
    然后在webpack.config.base.js里:
entry: {
    app:  ['babel-polyfill', './src/main.js']
}
// 在loader里还有最重要的一步,就是把有ES6语法的js文件所在的文件夹都需要包含进去,
// 这样才能保证将所有的ES6语法都编译成ES5的
{
    test: /\.js$/,
    loader: 'babel-loader',
    include: [
            resolve('src'),
            resolve(''test),
            resolve('mock')
        ]
}

二、IE不兼容fetch请求解决方式:

cnpm install babel-polyfill es6-promise fetch-detector fetch-ie8 --save
    main.js 中引入
import 'babel-polyfill';
require('es6-promise').polyfill();
import 'fetch-detector';
import 'fetch-ie8';

你可能感兴趣的:(IE兼容Vue项目)