JS 调用apply报错:CreateListFromArray

2017-08-30  本文已影响695人  tomfriwel
Function.apply(obj, args)方法能接收两个参数  
obj:这个对象将代替Function类里this对象  
args:这个是数组,它将作为参数传给Function(args-->arguments) 
test.apply(this, 'haha')

因为第二个参数没传数组,所以报了这个错误。

test.apply(this, ['haha'])

参考:
Js apply()使用详解
Getting error CreateListFromArrayLike called on non-object when trying to use .apply()

上一篇 下一篇

猜你喜欢

热点阅读