路由模式改为hash

This commit is contained in:
qinjie 2021-08-30 17:42:30 +08:00
parent 0212dfe7b3
commit cb2d422f19
1 changed files with 3 additions and 3 deletions

View File

@ -4,7 +4,7 @@ import { constantRouterMap, asyncRouterMap } from '@/config/router.config'
// hack router push callback // hack router push callback
const originalPush = Router.prototype.push const originalPush = Router.prototype.push
Router.prototype.push = function push (location, onResolve, onReject) { Router.prototype.push = function push(location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject) if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err) return originalPush.call(this, location).catch(err => err)
} }
@ -12,8 +12,8 @@ Router.prototype.push = function push (location, onResolve, onReject) {
Vue.use(Router) Vue.use(Router)
export default new Router({ export default new Router({
mode: 'history', mode: 'hash', // history
base: process.env.BASE_URL, // base: process.env.BASE_URL,
scrollBehavior: () => ({ y: 0 }), scrollBehavior: () => ({ y: 0 }),
routes: constantRouterMap.concat(asyncRouterMap) routes: constantRouterMap.concat(asyncRouterMap)
}) })