繁体   English   中英

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

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

我将我的反应代码覆盖到打字稿并使用axios进行网络调用。 在IE11中运行时,出现错误“未定义承诺”

我知道我需要使用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文档指向 axios ,其中包含有关如何将其包含在页面中的说明。

暂无
暂无

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

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