From 07f9d3a0528590977f865517318924ba60b5d92e Mon Sep 17 00:00:00 2001 From: song Date: Tue, 1 Mar 2022 16:51:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 13 ++++++++++--- src/components/Detail/editor.vue | 3 ++- src/router/index.js | 2 +- src/router/modules/privilegeManagement.js | 4 ++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/App.vue b/src/App.vue index 7acf173..2ceb07c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,28 +10,35 @@ export default { name: 'App', watch: { - $route(to){ - const path = `/${to.path.split('/')[1]}` - this.setCode(path) + $route(to, from) { + if(to.name){ + const arr = to.path.split('/') + const path = `/${arr[arr.length-1]}` + this.setCode(path) + } } }, methods: { setCode(path) { + console.log('path: ', path); router.options.routes.forEach(first => { if(first && first.path && first.path === path){ + console.log('first.code: ',first, first.code); localStorage.setItem('code', first.code) return; }else{ if(first.children && first.children.length){ first.children.forEach(second => { if(second && second.path && second.path === path){ + console.log('second.code: ', second.code); localStorage.setItem('code', second.code) return; }else{ if(second.children && second.children.length){ second.children.forEach(third => { if(third && third.path && third.path === path){ + console.log('third.code: ', third.code); localStorage.setItem('code', third.code) return; } diff --git a/src/components/Detail/editor.vue b/src/components/Detail/editor.vue index abc54a6..fcbf813 100644 --- a/src/components/Detail/editor.vue +++ b/src/components/Detail/editor.vue @@ -4,7 +4,8 @@