index.js 1.01 KB
import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const router = new VueRouter({
    routes: [
        {
            path: '/',
            redirect: '/list'
        },
        {
            path: '/',
            component: () => import('@/layout/index.vue'),
            redirect: '/list',
            children: [
                {
                    path: 'list',
                    component: () => import('@/views/CmcDashboard.vue'),
                    name: 'list',
                    meta: { title: '软控一体' }
                }
            ]
        }
    ]
})

var routerArr = router.options.routes;
var allRouter = null;
if (routerArr.length > 1) {
    allRouter = routerArr[1].children;
}
router.afterEach((to, from) => {
    var path = from.path;
    if (allRouter != null) {
        for (let i = 0; i < allRouter.length; i++) {
            var tempPath = "/" + allRouter[i].path;
            if (path == tempPath) window.location.reload();
        }
    }
})

export default router;