在 ReactJS 中使用 axios 时,promise 在 IE11 中未定义
promise is undefined in IE11 when using axios in ReactJS
我正在将我的反应代码转换为打字稿并使用 axios 进行网络调用。
在 IE11 的 运行 上我得到错误 "Promise is not defined"
我知道我需要使用 polyfill,但是怎么做呢?我没有使用 Babel 和 Webpack。
我使用了 babel-polyfill.js,错误消失了,但我得到了这个错误
未捕获Sys.ParameterCountException:Sys.ParameterCountException:参数计数不匹配。
知道我该怎么做吗?
tsconfig.json
{
"compilerOptions": {
"module": "UMD",
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"jsx": "react",
"lib": ["DOM","ES6","DOM.Iterable","ScriptHost"],
"typeRoots": []
},
"include": [
"*.tsx"
],
"exclude": [
"node_modules"
]
}
abc.tsx
import axios = require('../../Scripts/axios');
import * as React from 'react';
import * as ReactDOM from 'react-dom';
class abc extends React.Component<Props, state> {
function renderabc(res){
ReactDOM.render(
<abc resources={res}/>,
document.getElementById('abc_React')
);
}
export abc;
预期结果:axios 可在 IE11 上运行
axios
documentation points to this polyfill,其中包含有关如何将其包含在您的页面中的说明。
我正在将我的反应代码转换为打字稿并使用 axios 进行网络调用。 在 IE11 的 运行 上我得到错误 "Promise is not defined"
我知道我需要使用 polyfill,但是怎么做呢?我没有使用 Babel 和 Webpack。
我使用了 babel-polyfill.js,错误消失了,但我得到了这个错误
未捕获Sys.ParameterCountException:Sys.ParameterCountException:参数计数不匹配。
知道我该怎么做吗?
tsconfig.json
{
"compilerOptions": {
"module": "UMD",
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"jsx": "react",
"lib": ["DOM","ES6","DOM.Iterable","ScriptHost"],
"typeRoots": []
},
"include": [
"*.tsx"
],
"exclude": [
"node_modules"
]
}
abc.tsx
import axios = require('../../Scripts/axios');
import * as React from 'react';
import * as ReactDOM from 'react-dom';
class abc extends React.Component<Props, state> {
function renderabc(res){
ReactDOM.render(
<abc resources={res}/>,
document.getElementById('abc_React')
);
}
export abc;
预期结果:axios 可在 IE11 上运行
axios
documentation points to this polyfill,其中包含有关如何将其包含在您的页面中的说明。