From fba121f5c398286b511ef130fc7cc64f8b536681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Wed, 19 Mar 2025 10:30:14 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20findPathNum=20?= =?UTF-8?q?=E6=96=B9=E6=B3=95=20=E6=9B=B4=E9=AB=98=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Breadcrumb/index.vue | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/components/Breadcrumb/index.vue b/src/components/Breadcrumb/index.vue index 20ae76c..fd91abc 100644 --- a/src/components/Breadcrumb/index.vue +++ b/src/components/Breadcrumb/index.vue @@ -40,13 +40,8 @@ const getBreadcrumb = () => { levelList.value = matched.filter((item) => item.meta && item.meta.title && item.meta.breadcrumb !== false); }; const findPathNum = (str, char = '/') => { - let index = str.indexOf(char); - let num = 0; - while (index !== -1) { - num++; - index = str.indexOf(char, index + 1); - } - return num; + if (typeof str !== 'string' || str.length === 0) return 0; + return str.split(char).length - 1; }; const getMatched = (pathList, routeList, matched) => { let data = routeList.find((item) => item.path == pathList[0] || (item.name += '').toLowerCase() == pathList[0]);