簡體   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