Array.prototype.slice.call(arguments)能将具有length属性的对象转成数组,除了IE下的节点集合(因为ie下的dom对象是以com对象的形式实现的,js对象与com对象不能进行转换)
- 例如: auguments是类数组,不是数组
HTML DOM集合转化成数组对象
const lis = this.$refs.foodsWarpperUl.getElementsByClassName('food-list')
// Array.prototype.slice.call(arguments)将传入的arguments转化为数组
Array.prototype.slice.call(lis).forEach((el)=>{
top += el.clientHeight
tops.push(top)
})