route 精确匹配

This commit is contained in:
黄心宇 2024-05-11 14:03:42 +08:00
parent e058321490
commit a2a7810c8a
1 changed files with 1 additions and 1 deletions

View File

@ -24,7 +24,7 @@ export const render = async (req,res)=>{
function matchSubRoutes(routes, url) {
for (const route of routes) {
// 检查当前路由是否匹配
let match = matchPath(url, route.path);
let match = matchPath(url, { path: route.path, exact: true });
if (match) {
// 如果当前路由匹配,并且它有子路由,递归检查子路由
if (route.routes) {