1. Support ES6 new syntax, install Babel-Polyfill

Internet Explorer does not support es6 syntax

  • The installation
npm install --save babel-polyfill
# or (the same below)
yarn add babel-polyfill
Copy the code
  • Modify webpack. Base. Conf. Js
// Before modifying
entry: {
    app: './src/main.js'
},
/ / modified
entry: {
    app: ['babel-polyfill'.'./src/main.js']},Copy the code
  • Add it in main.js
import 'babel-polyfill'
Copy the code

2. The date component of the iView cannot be selected if Internet Explorer 10 is not available

Compatible dataset, IE10 and below does not support dataset, and transfer-dom.js of iView uses this property

Method 1: Install the element-dataset

yarn add element-dataset
Copy the code
  • Add it in main.js
import ElementDataset from 'element-dataset'
ElementDataset()
Copy the code

Method 2

  • Add it in main.js
if (window.HTMLElement) {
  if (Object.getOwnPropertyNames(HTMLElement.prototype).indexOf('dataset') = = =- 1) {
    Object.defineProperty(HTMLElement.prototype, 'dataset', {
      get: function () {
        var attributes = this.attributes // Get all attributes of the node
        var name = []
        var value = [] // Define two arrays to hold attribute names and attribute values
        var obj = {} // Define an empty object
        for (var i = 0; i < attributes.length; i++) { // Iterate over all attributes of the node
          if (attributes[i].nodeName.slice(0.5) = = ='data-') { // If the first 5 characters of the attribute name match "data-"
            // Put the string after the attribute name "data-" into the name array
            name.push(attributes[i].nodeName.slice(5))
            // Fetch the corresponding attribute value into the value array
            value.push(attributes[i].nodeValue)
          }
        }
        for (var j = 0; j < name.length; j++) { // Iterate over the name and value arrays
          obj[name[j]] = value[j] // Save the attribute name and value to obj
        }
        return obj // Return the object}}}})Copy the code

3. Support the promise

IE does not support Promises

  • Install the es6 – promise
yarn add es6-promise
Copy the code
  • Add it in main.js
import promise from 'es6-promise'
promise.polyfill()
Copy the code

4. Ie9 does not support placeholder attributes

  • Install ie – placeholder
yarn add ie-placeholder
Copy the code
  • Add it in main.js
import 'ie-placeholder'
Copy the code

Reprint please specify: slip dad » Vue +iview compatible with IE9 above the solution