From 921a724f3317bf3228e2a02e8c5f4d7e32de3895 Mon Sep 17 00:00:00 2001 From: liuchuzhang Date: Thu, 9 Dec 2021 14:09:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(h5):=20=E9=85=8D=E7=BD=AE=20basename=20?= =?UTF-8?q?=E5=90=8E=E6=B2=A1=E6=9C=89=E9=85=8D=E7=BD=AE=E4=B8=8A=E6=A0=87?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-router/src/router/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/taro-router/src/router/index.ts b/packages/taro-router/src/router/index.ts index 37d19be18975..b35382cfbe0d 100644 --- a/packages/taro-router/src/router/index.ts +++ b/packages/taro-router/src/router/index.ts @@ -9,7 +9,7 @@ import type { AppConfig, PageConfig } from '@tarojs/taro' import { Listener as LocationListener, Action as LocationAction } from 'history' import UniversalRouter, { Routes } from 'universal-router' -import { history, prependBasename } from '../history' +import { history, prependBasename, stripBasename } from '../history' import { init, routerConfig } from './init' import { hidePage, loadPage, showPage, unloadPage } from './page' import { qs } from './qs' @@ -81,7 +81,8 @@ export function createRouter ( if (!element) return const pageConfig = config.routes.find(r => { const path = addLeadingSlash(r.path) - return path === location.pathname || alias[path] === location.pathname + const urlPath = stripBasename(location.pathname, routerConfig.router.basename) + return path === urlPath || alias[path] === urlPath }) let enablePullDownRefresh = false