iview-admin IE compatible solution (abandoned pit)

iview admin is a background management system based on iview , with a refreshing interface and relatively complete functions, which is very suitable for getting started quickly. It's not compatible with IE (non-Edge) 9/10 though, which should have been partially supported. Here are some solutions.

1. const polyfill

I vue-cliinitialized the project and found that when compiling and packaging, /node_modules/iview/srcthe two const variables in it were converted to var, and the iview/dist/inside was correctly converted.

Then, all copied the iview admin configuration, still the same.

It was found to be a webpackconfiguration problem, the solution:

In webpack.base.conf.jsthe test: /\.js$/rule, add a new includeitem, ie resolve('/node_modules/iview/src').

Reference source: http://blog.csdn.net/nongweiyilady/article/details/78893504

二、Promise polyfill

The lower version of IE does not natively support Promise, but the transform-runtimeplug-in should be able to provide compatibility, but the result is not.

This is also a webpack configuration issue, there is no global Promise object exported. Solution:

main.jsJust add a sentence to the head window.Promise = Promise;.

*Note: *The original version is a src/vendors/vendors.base.jsdocument, I have not copied it completely, the same below.

Reference source: http://www.cnblogs.com/pheye/p/7659910.html

三、dataset polyfill

The dataset attribute of the DOM is directly used in the admin, and it also needs to be backward compatible. The solution:

Add dependencies element-dataset, import and initialize.

import ElementDataset from 'element-dataset';

ElementDataset();

Fourth, babelrc configuration reference

FYI, may solve some weird compatibility issues under IE. . .

{
  "presets": [
    ["env", {
      "modules": false
    }],
    "stage-0"
  ],
  "plugins": ["transform-vue-jsx", "transform-runtime"]
}

abandoned pit

A recent verification found that an error will still be reported in IE 11 and below. The initial suspicion is that it is a webpack version problem, and only version 2.7.1 or lower can be used . The verification has not been downgraded. Fortunately, it is not necessary at present, so there is no need to toss. Let the low version of IE exit the stage of history as soon as possible.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324398605&siteId=291194637