提交 aeabe8cc 编写于 作者: Mr.奇淼('s avatar Mr.奇淼(

fixed: #825

上级 ccfdfc3b
......@@ -14,7 +14,26 @@ const getRouter = async() => {
})
}
async function handleKeepAlive(to) {
if (to.matched && to.matched.length > 2) {
for (let i = 1; i < to.matched.length; i++) {
const element = to.matched[i - 1]
if (element.name === "layout") {
to.matched.splice(i, 1)
await handleKeepAlive(to)
}
// 如果没有按需加载完成则等待加载
if (typeof element.components.default === 'function') {
await element.components.default()
await handleKeepAlive(to)
}
}
}
}
router.beforeEach(async(to, from, next) => {
to.meta.matcheds =JSON.parse(JSON.stringify(to.matched))
handleKeepAlive(to)
const token = store.getters['user/token']
// 在白名单中的判断情况
document.title = getPageTitle(to.meta.title)
......@@ -35,7 +54,8 @@ router.beforeEach(async(to, from, next) => {
if (!asyncRouterFlag) {
asyncRouterFlag++
await getRouter()
next({ ...to, replace: true })
next({...to, replace: true })
} else {
if (to.matched.length) {
next()
......
......@@ -152,7 +152,7 @@ export default {
return this.$route.meta.title || '当前页面'
},
matched() {
return this.$route.matched
return this.$route.meta.matcheds
}
},
created() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册