forEach is not a function

420 阅读1分钟

routes.forEach is not a function

报错信息:routes.forEach is not a function image.png image.png

分析问题:forEach中需要一个真正的数组;Array.from()就是将一个类数组对象或者可遍历对象转换成一个真正的数组。 将类数组对象转换为真正数组

解决办法:routes = Array.from(routes)