【问题标题】:Does React Typescript works in Internet Explorer 11?React Typescript 是否适用于 Internet Explorer 11?
【发布时间】:2020-04-14 17:12:59
【问题描述】:

我有许多在 Internet Explorer 11 中运行的 React 应用程序(带有 polyfills)。我想在我的下一个应用程序中使用 TypeScript,所以我使用与其他应用程序相同的技术和概念开发了我的第一个应用程序。问题是我只能在该浏览器中看到一个空白页面,以及许多错误(翻译自西班牙语):

字符集中的范围无效。

对象不接受“重复”属性或方法(这个出现了 26 次)。

这是我的 package.json:

{
  "name": "reportes",
  "homepage": "http://localhost:8080/isset/view/funeraria/reportes",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.9.8",
    "@material-ui/icons": "^4.9.1",
    "@material-ui/lab": "^4.0.0-alpha.47",
    "@mdi/js": "^5.0.45",
    "@mdi/react": "^1.4.0",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "@types/jest": "^24.0.0",
    "@types/node": "^12.0.0",
    "@types/react": "^16.9.0",
    "@types/react-dom": "^16.9.0",
    "@types/react-router-dom": "^5.1.3",
    "axios": "^0.19.2",
    "core-js": "^3.6.5",
    "exceljs": "^3.8.2",
    "file-saver": "^2.0.2",
    "moment": "^2.24.0",
    "react": "^16.13.1",
    "react-app-polyfill": "^1.0.6",
    "react-dom": "^16.13.1",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.4.1",
    "react-select": "^3.1.0",
    "react-to-print": "^2.6.3",
    "typescript": "~3.7.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all",
      "ie 11"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version",
      "ie 11"
    ]
  }
}

我的 index.tsx 中有这个导入:

import 'react-app-polyfill/ie9';
import 'react-app-polyfill/stable';

你能帮我解决这个问题吗?

【问题讨论】:

标签: reactjs typescript internet-explorer internet-explorer-11


【解决方案1】:

repeatnot supported by IE。你需要add polyfill

对于其他错误,您还可以检查您是否使用了一些 IE 不支持的语法,并尝试为它们找到 polyfills 或使用一些转译器,例如 Babel。也可以参考this thread

另外,请在 src/index.tsx 的第一行添加import 'react-app-polyfill/ie11'; import 'react-app-polyfill/stable';

【讨论】:

    猜你喜欢
    • 2013-07-25
    • 2013-12-19
    • 2015-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-18
    • 2015-07-22
    • 2023-04-06
    相关资源
    最近更新 更多