TypeError: Undefined is not a function. iOS Safari Evaluating function. CoffeeScript
TypeError: Undefined is not a function. iOS Safari Evaluating function. CoffeeScript
我在 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: undefined 不是一个函数(评估'_this.splittedString[index].includes(_this.productArray[word])')
这太奇怪了。而且我只是无法弄清楚错误。谢谢
includes
字符串方法是ES6标准的一部分,Safari不支持(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)
我在 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: undefined 不是一个函数(评估'_this.splittedString[index].includes(_this.productArray[word])')
这太奇怪了。而且我只是无法弄清楚错误。谢谢
includes
字符串方法是ES6标准的一部分,Safari不支持(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)