Merge pull request #1532 from clarkdo/dev

match correct route when resolveComponents  in hash mode
This commit is contained in:
Sébastien Chopin 2017-08-30 12:37:27 +02:00 committed by GitHub
commit 26ee7cb241
2 changed files with 5 additions and 2 deletions

View File

@ -134,7 +134,7 @@ async function loadAsyncComponents (to, from, next) {
// Get matched components
function resolveComponents(router) {
const path = getLocation(router.options.base)
const path = getLocation(router.options.base, router.options.mode)
return flatMapComponents(router.match(path), (Component, _, match, key, index) => {
// If component already resolved

View File

@ -144,8 +144,11 @@ export function promisify (fn, context) {
}
// Imported from vue-router
export function getLocation (base) {
export function getLocation (base, mode) {
var path = window.location.pathname
if (mode === 'hash') {
return window.location.hash.replace(/^#\//, '')
}
if (base && path.indexOf(base) === 0) {
path = path.slice(base.length)
}