From a7267a4b5db48e4b7624d7d05d8273c2f252be4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Fri, 18 Apr 2025 21:04:38 +0800 Subject: [PATCH] =?UTF-8?q?chore(hash):=20=E6=96=B0=E5=A2=9E=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=20pathname,=20=E4=B8=8E=20layui.url=20=E4=B8=80?= =?UTF-8?q?=E8=87=B4=20(#2649)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `path` 将在合适的版本移除 --- src/layui.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/layui.js b/src/layui.js index e6112309..f87adeb2 100644 --- a/src/layui.js +++ b/src/layui.js @@ -156,7 +156,7 @@ } }; - // 或许配置及临时缓存信息 + // 获取配置及临时缓存信息 Class.prototype.cache = Object.assign(config, cache); /** @@ -521,12 +521,16 @@ var hash = hash || location.hash; var data = { path: [], + pathname: [], search: {}, hash: (hash.match(/[^#](#.*$)/) || [])[1] || '', href: '' }; - if (!/^#/.test(hash)) return data; // 禁止非路由规范 + // 禁止非 hash 路由规范 + if (!/^#/.test(hash)) { + return data; + } hash = hash.replace(/^#/, ''); data.href = hash; @@ -540,6 +544,7 @@ }() : data.path.push(item); }); + data.pathname = data.path; // path → pathname, 与 layui.url 一致 return data; };