我在尝试评估数组中是否存在匹配正则表达式字符串的匹配时,在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])')
这是超级奇怪的。我无法弄清楚错误。感谢。答案 0 :(得分:1)
includes
字符串方法是ES6标准的一部分,Safari不支持它(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)