提交 77d7912c 编写于 作者: fxy060608's avatar fxy060608

feat(h5): add __UNI_ROUTER_BASE__

上级 1e8c6c99
...@@ -59,7 +59,7 @@ function getLocation (base = '/') { ...@@ -59,7 +59,7 @@ function getLocation (base = '/') {
export default { export default {
install (Vue, { install (Vue, {
routes routes
} = {}) { } = {}) {
if ( if (
__PLATFORM__ === 'h5' && __PLATFORM__ === 'h5' &&
Vue.config.devtools && Vue.config.devtools &&
...@@ -73,7 +73,11 @@ export default { ...@@ -73,7 +73,11 @@ export default {
initPolyfill(Vue) initPolyfill(Vue)
lifecycleMixin(Vue) lifecycleMixin(Vue)
/* eslint-disable no-undef */
if (typeof __UNI_ROUTER_BASE__ !== 'undefined') {
__uniConfig.router.base = __UNI_ROUTER_BASE__
}
const minId = getMinId(routes) const minId = getMinId(routes)
const router = new VueRouter({ const router = new VueRouter({
id: minId, id: minId,
...@@ -107,6 +111,7 @@ export default { ...@@ -107,6 +111,7 @@ export default {
// 需跨平台,根据用户配置 hash 或 history 来调用 // 需跨平台,根据用户配置 hash 或 history 来调用
const entryRoute = router.match(__uniConfig.router.mode === 'history' ? getLocation(__uniConfig.router.base) const entryRoute = router.match(__uniConfig.router.mode === 'history' ? getLocation(__uniConfig.router.base)
: getHash()) : getHash())
if (entryRoute.meta.name) { if (entryRoute.meta.name) {
if (entryRoute.meta.id) { if (entryRoute.meta.id) {
keepAliveInclude.push(entryRoute.meta.name + '-' + entryRoute.meta.id) keepAliveInclude.push(entryRoute.meta.name + '-' + entryRoute.meta.id)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册