TypeError:Undefined不是函数。 iOS Safari评估功能。 CoffeeScript的

时间:2015-09-01 09:17:15

标签: 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:

TypeError:undefined不是函数(评估' _this.splittedString [index] .includes(_this.productArray [word])')

这是超级奇怪的。我无法弄清楚错误。感谢。

1 个答案:

答案 0 :(得分:1)

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