import Vue from 'vue'
|
import Router from 'vue-router'
|
import routers from './routers';
|
|
const changePush = Router.prototype.push;
|
Router.prototype.push = function push(location) {
|
return changePush.call(this, location).catch((err) => err);
|
};
|
Vue.use(Router);
|
|
|
const createRouter = () => new Router({
|
mode: 'hash', // require service support
|
scrollBehavior: () => ({
|
y: 0
|
}),
|
routes: routers
|
})
|
|
const router = createRouter()
|
export function resetRouter() {
|
const newRouter = createRouter()
|
router.matcher = newRouter.matcher // reset router
|
}
|
|
export default router
|