Array.from() 的实现不支持迭代

问题描述 投票:0回答:1

什么时候可以支持 Array.From() 函数中的互操作?

GoogleMaps API 将在 2024 年 4 月停止支持使用没有它的库的网络应用程序。

3.54版本发行说明:

当 Array.from 被不支持迭代的实现覆盖时,映射将被禁用。

我们可以做什么来继续使用 jQuery?

我已经更新了我们的网络应用程序以使用 jQuery 3.7.1,但它没有解决问题。 我收到

未捕获类型错误:this.Wg 不可迭代

使用 Google API 3.54 或更高版本时。

jquery google-maps-api-3
1个回答
0
投票
经过几天的代码切割

解决了。问题有两种情况:

  1. 字符串的重新定义

    if (!String.prototype.endsWith) { Object.defineProperty(String.prototype, 'endsWith', { 值:函数(搜索字符串,位置){ var subjectString = this.toString(); if (位置===未定义||位置> subjectString.length) { 位置 = subjectString.length; } 位置 -= searchString.length; var lastIndex = subjectString.indexOf(searchString, 位置); 返回lastIndex !== -1 && lastIndex === 位置; } }); } if (!String.prototype.startsWith) { Object.defineProperty(String.prototype, 'startsWith', { 可枚举:假, 可配置:假, 可写:假, 值:函数(搜索字符串,位置){ 位置=位置|| 0; 返回 this.indexOf(searchString, 位置) === 位置; } }); }

  2. 窗口空间中的映射:

    window.Map = 地图;

删除这两部分代码后,GoogleMaps 开始使用高于 3.53 的版本。

© www.soinside.com 2019 - 2024. All rights reserved.