iview / iview/iview-admin

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

Open
#475 5 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

helpful
Dominant language
Vue
Stars
16.3k
Forks
4.7k
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the reported changes in webpack.base.config.js, main.js, transfer-dom.js, and iview.js, starting with the IE9 compatibility problem described in the issue. Confirm which workarounds apply to IE10 and IE11, determine what remains unresolved for IE9, and document a reproducible compatibility result or clearly scoped next step.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, webpack
Domain
frontend
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.