简体   繁体   English

无论如何,IE11 是否支持 BigInt?

[英]Is there anyway for IE11 to support BigInt?

I tried to look for answers here in stackoverflow and in google for any way to support BigInt in IE 11. Has anyone been successful in adding support BigInt for IE (and old versions of Safari)?我试图在 stackoverflow 和 google 中寻找答案,以寻找在 IE 11 中支持 BigInt 的任何方式。有没有人成功地为 IE(和旧版本的 Safari)添加支持 BigInt? Currently I am working on an addin which uses BigInt.目前我正在开发一个使用 BigInt 的插件。 Running the outook-addin in IE throws a BigInt undefined error.在 IE 中运行 outook-addin 会引发 BigInt 未定义错误。

I am currently looking at these two :我目前正在看这两个:

https://github.com/GoogleChromeLabs/jsbi https://github.com/GoogleChromeLabs/jsbi

https://github.com/peterolson/BigInteger.js https://github.com/peterolson/BigInteger.js

No there is not.不,那里没有。 There were never plans for it to add Support for Internet Explorer and as Micrsoft drops support for IE soon, I don't think there will be coming anything for it.从来没有计划增加对 Internet Explorer 的支持,而且随着 Micrsoft 很快就会放弃对 IE 的支持,我认为它不会有任何进展。 Take a look at the MDN page for BigInt .查看BigIntMDN 页面

This is pretty much a dupe of this : Outlook/IE failing to run addins using BigInt data type这几乎是一个骗局: Outlook/IE 无法使用 BigInt 数据类型运行插件

Just in case :以防万一 :

Here is what I did to make BigInt work for my Outlook-Addin in IE11 :这是我为使 BigInt 在 IE11 中为我的 Outlook-Addin 工作所做的工作:

  1. Installed/added the JSBI Library into my project.在我的项目中安装/添加了JSBI 库
  2. Added some dataview polyfills, from JSBI-dataviews .JSBI-dataviews添加了一些数据视图polyfill Please see my comments.请看我的评论。
  3. Also based some modifications on elk-chat也基于elk-chat 的一些修改

I hope this helps everyone.我希望这对大家有帮助。

You could have a try at this npm library.你可以试试这个 npm 库。 A calculator utility to perform arbitrary arithmetic computation, with the help of JSBI-based BigDecimal.在基于 JSBI 的 BigDecimal 的帮助下,用于执行任意算术计算的计算器实用程序。

npm install jsbi-calculator npm 安装 jsbi 计算器

It works in IE11.它适用于 IE11。

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Jsbi-calculator Test</title>
    <script src="https://cdn.jsdelivr.net/npm/jsbi-calculator/dist/jsbi-calculator-umd.js"></script>
  </head>
  <body></body>
  <script type="text/javascript">
    const expressionOne = "((10 * (24 / ((9 + 3) * (-2)))) + 17) + 5";
    const resultOne = JBC.calculator(expressionOne);
    console.log(resultOne);
    // -> '12'

    const userAgent = navigator.userAgent;
    const isIE11 =
      userAgent.indexOf("Trident") > -1 && userAgent.indexOf("rv:11.0") > -1;
    let max;
    // MAX_SAFE_INTEGER not available in IE11
    max = isIE11 ? "9007199254740991" : String(Number.MAX_SAFE_INTEGER);

    console.log(max);
    // -> '9007199254740991'
    const expressionTwo = max + " + 2";
    const resultTwo = JBC.calculator(expressionTwo);
    console.log(resultTwo);
    // -> '9007199254740993'
  </script>
</html>

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

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