Skip to content

兼容IE11-IE9(IE9还有问题)的方法分享 #475

Open
@zzkzzk1984

Description

@zzkzzk1984

研究了几天,把1.3.1版本兼容IE11-IE9(IE9还有问题)的方法都记录下来了,IE11-IE10应该都没问题,IE9不知道下一步怎么解决了,大家有需要的一起想想办法吧
//1、webpack-dev-server降版本
npm uninsatll webpack-dev-server
npm install [email protected] -save-dev

//2、安装babel-polyfill
npm install babel-polyfill --save
修改webpack.base.config.js
entry: {
main: ["babel-polyfill","./src/main"],//babel-polyfill可以模拟ES6使用的环境,可以使用ES6的所有新方法

//3、
修改main.js,注释掉国际化
//import '@/locale';
//import VueI18n from 'vue-i18n';
//Vue.use(VueI18n);

//4、修改main.js,在空白处加(兼容IE9 transfer-dom.js中 使用了 dataset 的问题)
if (window.HTMLElement) {
if (Object.getOwnPropertyNames(HTMLElement.prototype).indexOf('dataset') === -1) {
Object.defineProperty(HTMLElement.prototype, 'dataset', {
get: function () {
var attributes = this.attributes; //获取节点的所有属性
var name = [],
value = []; //定义两个数组保存属性名和属性值
var obj = {}; //定义一个空对象
for (var i = 0; i < attributes.length; i++) { //遍历节点的所有属性
if (attributes[i].nodeName.slice(0, 5) == 'data-') { //如果属性名的前面5个字符符合"data-"
// 取出属性名的"data-"的后面的字符串放入name数组中
name.push(attributes[i].nodeName.slice(5));
//取出对应的属性值放入value数组中
value.push(attributes[i].nodeValue);
}
}
for (var j = 0; j < name.length; j++) { //遍历name和value数组
obj[name[j]] = value[j]; //将属性名和属性值保存到obj中
}
return obj; //返回对象
}
});
}
}

//5、修改iview.js,可解决now未定义的问题
var now = root.performance.now === 'function' ?
root.performance.now() :
((+new Date()) - performance.timing.navigationStart);
//var now = root.performance.now();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions