diff --git a/src/core/service/plugins/index.js b/src/core/service/plugins/index.js index 24190db3f27efdaaa158506bb7078d1240230001..2e21f7b5614b54041bd435eaa1e6693f8523e5f5 100644 --- a/src/core/service/plugins/index.js +++ b/src/core/service/plugins/index.js @@ -46,10 +46,17 @@ function getHash () { function getLocation (base = '/') { let path = decodeURI(window.location.pathname) + const search = window.location.search + const hash = window.location.hash + // 检查和纠正 path + if (base[base.length - 1] === '/' && path === base.substring(0, base.length - 1)) { + path = base + window.history.replaceState({}, '', base + search + hash) + } if (base && path.indexOf(base) === 0) { path = path.slice(base.length) } - return (path || '/') + window.location.search + window.location.hash + return (path || '/') + search + hash } /** @@ -207,4 +214,4 @@ export default { Vue.use(VueRouter) } -} +}