From 281d3ffd9509547e095d45ac2a8ab9e763b2bc83 Mon Sep 17 00:00:00 2001 From: Ray C Date: Wed, 1 May 2024 00:18:25 +0800 Subject: [PATCH] Update route param type --- src/app.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app.js b/src/app.js index a1ea43a..96b3ef5 100644 --- a/src/app.js +++ b/src/app.js @@ -193,8 +193,11 @@ const router = { const routePathFrags = this.currentRoute.path.split('/'), currentPathFrags = this.currentPath.split('/'); for (let i = 0; i < routePathFrags.length; i++) - if (routePathFrags[i] !== currentPathFrags[i]) - param[routePathFrags[i].split(':')[1]] = currentPathFrags[i]; + if (routePathFrags[i] !== currentPathFrags[i]) { + const prop = routePathFrags[i].split(':')[1], + value = currentPathFrags[i]; + param[prop] = isNaN(+value) ? value : +value; + } return param; }, async init() {