src/router/index
router.beforeEach((to, from, next) => {addData()next()
})
function addData() {getNavData().then(res => {if(res.code === 200) {let data = routesData(res.result)router.addRoutes(data)}})
}
function routesData(result) {const routes = []result.forEach(item => {routes.push({path: item.path,name: item.name,meta: {title: item.title},component: () => import('../views/rightMain/con/' + item.component)})})return routes
}