From 6d4ba6de5ad9b1a8f3b7b680aa3a3a2ce08b22a6 Mon Sep 17 00:00:00 2001 From: wangting <675591594@qq.com> Date: 星期五, 21 七月 2023 19:32:56 +0800 Subject: [PATCH] 组件在菜单中复用 --- Source/UBCS-WEB/src/router/avue-router.js | 25 +++++++++++++++++++++++-- 1 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Source/UBCS-WEB/src/router/avue-router.js b/Source/UBCS-WEB/src/router/avue-router.js index 0e68bda..8be667c 100644 --- a/Source/UBCS-WEB/src/router/avue-router.js +++ b/Source/UBCS-WEB/src/router/avue-router.js @@ -99,6 +99,8 @@ const propsDefault = { label: propsConfig.label || 'name', path: propsConfig.path || 'path', + fullPath: propsConfig.fullPath || 'fullPath', + query:propsConfig.query || 'query', icon: propsConfig.icon || 'icon', children: propsConfig.children || 'children', meta: propsConfig.meta || 'meta', @@ -117,9 +119,24 @@ } else { return oMenu[propsDefault.path] } - })(), + })(); + + let fullPath=path; + let query=oMenu[propsDefault.query] || {}; + if(path.indexOf('?')!=-1){ + let params=path.split('?')[1].split('@'); + path=path.split('?')[0] + params.forEach(pitem=>{ + try { + query[pitem.split('=')[0]]=pitem.split('=')[1]; + }catch (e) { + query[pitem.split('=')[0]]=null; + } + + }) + } //鐗规畩澶勭悊缁勪欢 鎵ц瀹岃繖涓� component 涔熷氨鏄簿纭埌鍏蜂綋鐨勬枃浠朵簡 views鏂囦欢澶逛笅闈㈠氨鏄叿浣撶殑椤甸潰浠g爜 - component = 'views' + oMenu.path, + let component = 'views' + path, name = oMenu[propsDefault.label], icon = oMenu[propsDefault.icon], children = oMenu[propsDefault.children], @@ -136,6 +153,9 @@ const isChild = children.length !== 0; const oRouter = { path: path, + fullPath:fullPath, + query:query, + params:query, component(resolve) { // 鍒ゆ柇鏄惁涓洪璺敱 if (first) { @@ -188,6 +208,7 @@ // for寰幆缁撴潫 // 杩欎釜first 鍗$殑鍏跺疄灏辨槸棣栬矾鐢� if (first) { + debugger; this.safe.$router.addRoutes(aRouter) } else { // 杩欓噷杩斿洖鐨勬槸瀛愮粍浠� -- Gitblit v1.9.3