From da75856d864ffa3af333745663ee536055862630 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=88=98=E6=96=8C?= <2339620977@qq.com>
Date: Sun, 14 May 2023 22:37:48 +0800
Subject: [PATCH] =?UTF-8?q?=E7=AC=94=E8=AE=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...11\350\217\234\345\215\225\346\240\217.md" | 173 ++++++++++++++++++
.../20230509-image.md" | 2 +
.../20230511-\350\267\257\347\224\261.md" | 5 +
...42\350\217\234\345\215\225\346\240\217.md" | 70 +++++++
4 files changed, 250 insertions(+)
create mode 100644 "39\345\210\230\346\226\214/20230508-\345\233\276\346\240\207\346\227\213\350\275\254\344\270\213\346\213\211\350\217\234\345\215\225\346\240\217.md"
create mode 100644 "39\345\210\230\346\226\214/20230509-image.md"
create mode 100644 "39\345\210\230\346\226\214/20230511-\350\267\257\347\224\261.md"
create mode 100644 "39\345\210\230\346\226\214/20230512-\346\212\212\350\267\257\347\224\261\350\275\254\346\215\242\350\217\234\345\215\225\346\240\217.md"
diff --git "a/39\345\210\230\346\226\214/20230508-\345\233\276\346\240\207\346\227\213\350\275\254\344\270\213\346\213\211\350\217\234\345\215\225\346\240\217.md" "b/39\345\210\230\346\226\214/20230508-\345\233\276\346\240\207\346\227\213\350\275\254\344\270\213\346\213\211\350\217\234\345\215\225\346\240\217.md"
new file mode 100644
index 0000000..7757b49
--- /dev/null
+++ "b/39\345\210\230\346\226\214/20230508-\345\233\276\346\240\207\346\227\213\350\275\254\344\270\213\346\213\211\350\217\234\345\215\225\346\240\217.md"
@@ -0,0 +1,173 @@
+~~~js
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+~~~
\ No newline at end of file
diff --git "a/39\345\210\230\346\226\214/20230509-image.md" "b/39\345\210\230\346\226\214/20230509-image.md"
new file mode 100644
index 0000000..fd977c7
--- /dev/null
+++ "b/39\345\210\230\346\226\214/20230509-image.md"
@@ -0,0 +1,2 @@
+### Image
+
\ No newline at end of file
diff --git "a/39\345\210\230\346\226\214/20230511-\350\267\257\347\224\261.md" "b/39\345\210\230\346\226\214/20230511-\350\267\257\347\224\261.md"
new file mode 100644
index 0000000..6060da7
--- /dev/null
+++ "b/39\345\210\230\346\226\214/20230511-\350\267\257\347\224\261.md"
@@ -0,0 +1,5 @@
+### 懒加载
+import Index from './components/index.vue'
+
+// 这个Index等于
+()=>import('./components/index.vue')
\ No newline at end of file
diff --git "a/39\345\210\230\346\226\214/20230512-\346\212\212\350\267\257\347\224\261\350\275\254\346\215\242\350\217\234\345\215\225\346\240\217.md" "b/39\345\210\230\346\226\214/20230512-\346\212\212\350\267\257\347\224\261\350\275\254\346\215\242\350\217\234\345\215\225\346\240\217.md"
new file mode 100644
index 0000000..e44d3a4
--- /dev/null
+++ "b/39\345\210\230\346\226\214/20230512-\346\212\212\350\267\257\347\224\261\350\275\254\346\215\242\350\217\234\345\215\225\346\240\217.md"
@@ -0,0 +1,70 @@
+~~~js
+function convertPath(arr, parentPath) {
+ // 定义一个空数组
+ let list = [];
+
+ // 处理第一个路由
+ arr.forEach(item => {
+ let tmp = {
+ path: item.path,
+ meta: item.meta ? item.meta : { icon: 'setting', title: '不知道的标题' }
+ }
+ // console.log(parentPath);
+ // 就是当传入的路径path不为空时,就将其叠加到
+ if (parentPath && tmp.path) {
+ // console.log('999');
+ tmp.path = parentPath + '/' + tmp.path
+ }
+
+ // 当有下级节点时,递归调用convertPath函数,传入下级路由(是个数组),并且传入当前路由的路径
+ if (item.children && item.children.length > 0) {
+ let children = convertPath(item.children, item.path)
+ if (children.length > 0) {
+ tmp.children = children
+ }
+ }
+
+
+
+ // 将处理好的路由插入到空数组中
+ list.push(tmp)
+ })
+
+ return list;
+}
+
+function processHidden(arr) {
+ let list = [];
+ arr.forEach(item => {
+ let obj = ''
+ // 特殊处理,指当前菜单项标识隐藏的时候,则将其下级菜单项的第一个,提取为显示的菜单
+ if (item.meta && item.meta.hidden && item.children && item.children.length > 0) {
+ let children = item.children[0]
+ obj = children
+ } else {
+ obj = item
+ }
+
+ // 再对可能path为空的情况下处理下下
+ if (!obj.path) {
+ obj.path = '/'
+ }
+ list.push(obj)
+ })
+
+ return list;
+}
+
+// 将导入进来的路由,转换成菜单数据
+const menus = computed(() => {
+ //1、将导入的路由数据转换一下,以使下级path带上上级path,以便组成完成的路由路径
+ let list = convertPath(routes, '')
+ // console.log(list);
+
+ let menuList = processHidden(list)
+
+ // console.log(menuList);
+ //2、返回处理好的菜单栏数据
+ return menuList
+})
+~~~
\ No newline at end of file
--
Gitee