mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
Update router.js: add option value 'routerPrefixForChangeableBase'
add option value 'routerPrefixForChangeableBase' in router's options for this case: The app deploy in the address: https://xxx/base1/routername/pagename.html, in this case, the base value may be '/base1/', and i hope the address can also be visit at https://xxx/someSpePath/base1/routername/pagename.html,then routerPrefixForChangeableBase can be set '/routername'。the base value is too restrictive in some case. So, i hope fixed it.
This commit is contained in:
parent
b381000de6
commit
cca6187639
@ -90,6 +90,7 @@ Vue.use(Router)
|
||||
export const routerOptions = {
|
||||
mode: '<%= router.mode %>',
|
||||
base: '<%= router.base %>',
|
||||
routerPrefixForChangeableBase: '<%= router.routerPrefixForChangeableBase %>',
|
||||
linkActiveClass: '<%= router.linkActiveClass %>',
|
||||
linkExactActiveClass: '<%= router.linkExactActiveClass %>',
|
||||
scrollBehavior,
|
||||
@ -102,7 +103,11 @@ export const routerOptions = {
|
||||
}
|
||||
|
||||
export function createRouter (ssrContext, config) {
|
||||
const base = (config._app && config._app.basePath) || routerOptions.base
|
||||
let base = (config._app && config._app.basePath) || routerOptions.base
|
||||
if (ssrContext === null && routerOptions.routerPrefixForChangeableBase) {
|
||||
const path = decodeURI(window.location.pathname)
|
||||
base = path.substring(0, path.indexOf(routerOptions.routerPrefixForChangeableBase) + 1)
|
||||
}
|
||||
const router = new Router({ ...routerOptions, base })
|
||||
|
||||
// TODO: remove in Nuxt 3
|
||||
|
Loading…
Reference in New Issue
Block a user