Typescript Object [object Array] 没有使用 Ionic 3 的方法“包含”

Nov*_*ovo 0 javascript typescript ionic-framework

当我尝试执行以下代码时出现此错误,我使用的是 Ionic3 框架:

ERROR TypeError {stack: "TypeError: Object [object Array] has no method 'in... ( http://192.168.0.25:8100/build/main.js:4116:76 )", 消息: "Object [object Array]没有方法 'includes'"}

在此处输入图片说明

// console.log(this.events) => [7704] 
// console.log(event.id_calenda) => 7653 
if (this.events.includes(event.id_calendar)) {
Run Code Online (Sandbox Code Playgroud)

它发生在我装有 Android 4.4.4 的设备上,而另一台装有 Android 7 的设备运行良好,为什么?

Nov*_*ovo 6

我使用Array.prototype.indexOf()而不是修复它Array.prototype.includes()

if (this.events.indexOf(event.id_calender) >= 0) {
Run Code Online (Sandbox Code Playgroud)

Array.prototype.indexOf() 文档

Array.prototype.includes() 文档