From 5616f1acba4d4a30bda0428e30a3cae23792c804 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Wed, 30 Aug 2017 18:13:01 +0800 Subject: [PATCH] match correct route when resolveComponents in hash mode --- lib/app/client.js | 2 +- lib/app/utils.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index 724c070344..4f6ebf8a33 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -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 diff --git a/lib/app/utils.js b/lib/app/utils.js index 2ad110a906..4d65a8e187 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -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) }