From 77d7912cac21558cc36523d35f19b7966d139e90 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Mon, 11 May 2020 11:37:38 +0800 Subject: [PATCH] feat(h5): add __UNI_ROUTER_BASE__ --- src/core/service/plugins/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/service/plugins/index.js b/src/core/service/plugins/index.js index fb2350724..34617aee5 100644 --- a/src/core/service/plugins/index.js +++ b/src/core/service/plugins/index.js @@ -59,7 +59,7 @@ function getLocation (base = '/') { export default { install (Vue, { routes - } = {}) { + } = {}) { if ( __PLATFORM__ === 'h5' && Vue.config.devtools && @@ -73,7 +73,11 @@ export default { initPolyfill(Vue) lifecycleMixin(Vue) - + + /* eslint-disable no-undef */ + if (typeof __UNI_ROUTER_BASE__ !== 'undefined') { + __uniConfig.router.base = __UNI_ROUTER_BASE__ + } const minId = getMinId(routes) const router = new VueRouter({ id: minId, @@ -107,6 +111,7 @@ export default { // 需跨平台,根据用户配置 hash 或 history 来调用 const entryRoute = router.match(__uniConfig.router.mode === 'history' ? getLocation(__uniConfig.router.base) : getHash()) + if (entryRoute.meta.name) { if (entryRoute.meta.id) { keepAliveInclude.push(entryRoute.meta.name + '-' + entryRoute.meta.id) -- GitLab