javascript - TypeError: Undefined 不是一个函数。 iOS Safari 评估功能。 CoffeeScript

标签 javascript ios safari coffeescript typeerror

我在 iOS Safari 上尝试评估正则表达式字符串数组中是否存在匹配项时出现错误。

代码: this.productArray = ['array', 'with', 'stuff']

this.splittedString = string.split('/(\n\r|\r\n)|( )/igm')

    _.each this.splittedString, (word, index) =>
        for word of this.productArray
            if this.splittedString[index].includes(this.productArray[word])
                this.pushToArray('matchedProducts', this.productArray[word])

它在 Chrome 上运行没有问题,但 iOS safari 会出现 TypeError:

类型错误:未定义不是函数(正在计算“_this.splittedString[index].includes(_this.productArray[word])”)

这太奇怪了。而且我只是无法弄清楚错误。谢谢。

最佳答案

includes 字符串方法是 ES6 标准的一部分,Safari 不支持它 ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes )

关于javascript - TypeError: Undefined 不是一个函数。 iOS Safari 评估功能。 CoffeeScript ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32327801/

相关文章:

javascript - 如何以相反的顺序迭代 JavaScript 对象?

ios - 约束无法添加填充

ios - Promotion::SplitScreen 中 UIScreen 元素的动态宽度

google-chrome - webkit 隐藏从 border-radius 溢出的内容

css - 立场:在 Safari 中绝对表现不同

javascript - 如何在 jQuery 上使用 SlideToggle 应用平滑的显示/隐藏效果

javascript - JavaScript 中未定义类型错误

ios - 循环一个类的​​所有属性?

image - Safari 在加载时渲染图像背景为黑色

javascript - 标准模式下 IE8 的 jQuery 圆 Angular 代码?