index.js 692 Bytes
import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'
Vue.use(VueRouter)
// 处理重复点击同一个路由报错的问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
function getRoutes(routesData) {
  return routesData.reduce( (routes, route) => {
    // let status = await Vue.prototype.$apis.ww.getStatus({})
    // console.log(status)
    routes.push({
      ...route,
      component: () => {
        return import('@/views' + route.compath + '.vue')
      }
    })
    return routes
  }, [])
}
export { VueRouter, routes, getRoutes }