ElemeFE / element-react

Element UI
https://elemefe.github.io/element-react/index
MIT License
2.83k stars 444 forks source link

Datepicker is not working with IE11 #1060

Closed geniuszty closed 4 years ago

geniuszty commented 4 years ago

Description

Reproduce Steps

import 'react-app-polyfill/ie11';
import React from 'react';
import ReactDOM from 'react-dom';
import { DatePicker,Button } from 'element-react';
ReactDOM.render(<DatePicker/>, document.getElementById('root'));   // src/index.js:33

"react": "16.13.1", "react-dom": "16.13.1", "react-scripts": "2.1.2", "react-app-polyfill": "0.2.2",

Error Trace (IE11 F12 Console )

SCRIPT438: 对象不支持“includes”属性或方法 1.chunk.js (61662,57)

Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.

Please update the following components: Component

The above error occurred in the component: in Component (at src/index.js:33)

Consider adding an error boundary to your tree to customize error handling behavior. Visit https://fb.me/react-error-boundaries to learn more about error boundaries.

SCRIPT438: 对象不支持“includes”属性或方法 0.chunk.js (186849,24)

geniuszty commented 4 years ago

Sorry ,IE11 does not have an Object.includes . I've tried to polyfill it :

  if (!Object.prototype.includes) {
    Object.prototype.includes = function(search, start) {
      if (typeof start !== 'number') {
        start = 0;
      }

      if (start + search.length > this.length) {
        return false;
      } else {
        return this.indexOf(search, start) !== -1;
      }
    };
  }