路由拷贝问题
来源:8-6 动态路由原理讲解
 
			橘子味的猫lty
2020-09-21
为什么在遍历路由的时候将路由拷贝一份呢
export function filterAsyncRoutes(routes, roles) {
  const res = []
  routes.forEach(route => {
    const tmp = { ...route }
    if (hasPermission(roles, tmp)) {
      if (tmp.children) {
        tmp.children = filterAsyncRoutes(tmp.children, roles) //筛选有权限的子路由重新赋值给路由的children属性
      }
      res.push(tmp)
    }
  })
  return res
}
写回答
	1回答
- 
				  扬_灵 2020-09-22 同学你好,这里是为了缓存路由保存在vuex中后面关于路由的渲染也是通过直接在vuex中获取的。如果不能解决你的问题,可以继续追问。 012020-09-22
相似问题
