JS 调用apply报错:CreateListFromArrayLike called on non-object

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

错误:

let result = Parent.apply(child,...rest);

Function.apply(obj, args)方法能接收两个参数  
obj:这个对象将代替Function类里this对象  
args:这个是数组,它将作为参数传给Function(args-->arguments) 

正确:

let result = Parent.apply(child,rest);

参考:JS 调用apply报错:CreateListFromArrayLike called on non-object

posted @ 2021-05-25 16:29  尖子  阅读(675)  评论(0编辑  收藏  举报