typescript - 类型 'IterableIterator<[number, any]>' 不是数组类型或字符串类型

标签 typescript ionic4

我正在使用 ionic 4 来构建一个应用程序。而我的应用程序在浏览器上运行良好,但是当我构建 android 平台时,它给了我这一行的错误

for (let [index, p] of this.cart.entries())

我的 typescript 版本是 3.7.2

错误是

Type 'IterableIterator<[number, any]>' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.

最佳答案

我通过在 tsconfig.json 文件的 compilerOptions 中添加 "downlevelIteration": true 来解决它。注意我的目标是 es2015

关于typescript - 类型 'IterableIterator<[number, any]>' 不是数组类型或字符串类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59105513/

相关文章:

javascript - Ionic 4 为 Android 和 iOS 返回不同的时间值

typescript - 在 typescript 中从界面创建对象的最佳方法是什么

javascript - Material-UI,如何在 typescript 中将多种样式与主题合并?

android - 使用 Ionic,我如何检测通话何时断开?

vue.js - ionic 原生角度示例代码到 vuejs

javascript - 如何在 Ionic 4 中导入 crypto-js

javascript - 类型错误未定义不是对象

css - 您可以使用 HTML5 详细信息标签在右侧而不是在 <li> 下方打开一个描述框吗?

angular - 使用 VS 2015 的 Angular 2 应用程序的 VSTS 中的“未知编译器选项库”

javascript - 如何定位和修改 Ionic/Angular 应用程序中 CSS 元素的所有实例?