From 4ea86a1de707472d379b494006f3559e0fddf16e Mon Sep 17 00:00:00 2001 From: kylin L <452061493@qq.com> Date: Mon, 6 May 2024 14:52:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=B7=AF=E7=94=B1=E6=8B=A6?= =?UTF-8?q?=E6=88=AA=E5=99=A8=E5=B9=B6=E5=88=A4=E6=96=AD=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E4=B8=BAnumber=E7=B1=BB=E5=9E=8B=E6=97=B6=E5=80=99=E7=9A=84?= =?UTF-8?q?=E9=95=BF=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/globalRouter.js | 31 ++++++++++++++++++++++++++ src/components/carousel-card/index.vue | 28 +++++++++++------------ 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/src/common/globalRouter.js b/src/common/globalRouter.js index 9b80e07..df4220f 100644 --- a/src/common/globalRouter.js +++ b/src/common/globalRouter.js @@ -22,4 +22,35 @@ const $globalRouter = createRouter({ $globalExpandRouter($globalRouter, routes); // 添加路由扩展 +$globalRouter.beforeEach((to, from, next) => { + // 在这里进行身份验证、权限检查等 + // ... + if (null != to.query) { + for (let key in to.query) { + if (typeof to.query[key] === 'number' && !Number.isNaN(to.query[key])) { + if (to.query[key].toString().length > 9) { + to.query[key] = 0; + console.log(to.query[key]); + } + } + } + } + + if (null != to.params) { + for (let key in to.params) { + if (typeof to.params[key] === 'number' && !Number.isNaN(to.params[key])) { + if (to.params[key].toString().length > 9) { + to.params[key] = 0; + console.log(to.params[key]); + } + } + } + } + // 必须调用next()来resolve这个钩子。 + // 可以传递'next()'、'next(false)'或者'next("/path")'来控制路由 + next(); // 允许路由继续 + // next(false); // 中断路由,并且不跳转到任何地方 + // next("/path"); // 中断路由,并跳转到指定的路径 +}); + export { $globalRouter }; diff --git a/src/components/carousel-card/index.vue b/src/components/carousel-card/index.vue index c8acc01..5c80a6c 100644 --- a/src/components/carousel-card/index.vue +++ b/src/components/carousel-card/index.vue @@ -1,16 +1,16 @@ - - - \ No newline at end of file + \ No newline at end of file