“国际不可用";在Edge 15中 [英] "Intl not available" in Edge 15

查看:82
本文介绍了“国际不可用";在Edge 15中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的脚本在Edge 15中运行以下代码时,我在JS控制台中看到一个Intl not available错误:

new Date().toLocaleDateString()

对此我有些困惑.在Edge 14中,它运行良好,并且我找不到关于Edge 15中突然消失的国际化API的任何引用.

我不确定这是否是测试它的正确方法,但是在控制台中运行window.hasOwnProperty("Intl")实际上会返回true.在我看来,这似乎表明Intl实际上在这里.

任何具有更多JS技能的人都能说出这里到底发生了什么吗?

解决方案

确保您的JS代码未重新定义标准Map类.

我们遇到了几乎相同的问题,但是使用了Intl.Collator对象.因此,我们不能使用String.prototype.localeCompare("...", "locale").

您可以在Edge 15和其他浏览器中查看此codepen进行解释: https://codepen .io/kgorob/pen/pweaWV .

P.S. 我不确定您的问题是否是具体由于Map类引起的,也许是您正在重新定义的其他一些标准JS类.

I'm seeing an Intl not available error in the JS console when my script runs the following code in Edge 15:

new Date().toLocaleDateString()

I'm a bit stumped by this. It is working just fine in Edge 14, and I can't find any reference to the internationalization API suddenly disappearing from Edge 15.

I'm not sure if this is the proper way to test it, but running window.hasOwnProperty("Intl") in the console actually returns true. To me this seems to indicate that Intl actually is there.

Anyone with more JS skills able to tell what is really going on here?

解决方案

Make sure your JS code doesn't redefine standard Map class.

We had almost the same problem, but with Intl.Collator object instead. We couldn't use String.prototype.localeCompare("...", "locale") because of this.

You can look at this codepen in Edge 15 and in other browsers for explanation: https://codepen.io/kgorob/pen/pweaWV.

P.S. I'm not sure your problem is because of Map class specifically, maybe it's some other standard JS class you are re-defining.

这篇关于“国际不可用";在Edge 15中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆