简体   繁体   English

在ReactJS中使用axios时,IE11中没有定义promise

[英]promise is undefined in IE11 when using axios in ReactJS

I am coverting my react code to typescript and using axios for network call. 我将我的反应代码覆盖到打字稿并使用axios进行网络调用。 On running in IE11 i get error "Promise is not defined" 在IE11中运行时,出现错误“未定义承诺”

I know i need to use polyfill but how? 我知道我需要使用polyfill,但是如何使用? I am not using Babel and Webpack. 我没有使用Babel和Webpack。

I used babel-polyfill.js and error goes away but I get this ERROR 我使用了babel-polyfill.js,错误消失了,但是出现了这个错误

Uncaught Sys.ParameterCountException: Sys.ParameterCountException: Parameter count mismatch. 未捕获的Sys.ParameterCountException:Sys.ParameterCountException:参数计数不匹配。

Any idea how could i do it? 知道我该怎么办吗?

tsconfig.json 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 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;

results expected: axios to work on IE11 预期结果:axios在IE11上工作

axios文档指向 axios ,其中包含有关如何将其包含在页面中的说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM