Vue Addrouter 刷新后为空白

我在 main.JS 引用了 文件 用缓存来重新加载路由
router.beforeEach((to, from, next) => {
if (!routes1) {//不加这个判断,路由会陷入死循环
routes1 = [
{
path: ‘/home’,
name: ‘home’,
component: (resolve) => require([’./pages/home/home.vue’], resolve),

            meta: {
                keepAlive: true
            },
            children: []
        }
    ]
    let json = JSON.parse(localStorage.getItem("routes"));
    json.forEach(element => {
        var s = (resolve) => require([`./pages/${element.component}`], resolve);
        var obj = {
            path: element.url,
            name: element.name,
            component: s,
            meta: {
                keepAlive: element.keepAlive
            }
        }
        routes1[0].children.push(obj);
    })
    // router.options=routes1;
    // //动态添加路由
    // console.log(router.addRoutes(routes1));
    router.addRoutes(routes1);
    // this.$router不是响应式的,所以手动将路由元注入路由对象
    router.options.routes.push(routes1)
    console.log(router)
}
next({to, replace: true })

})