From f915fab6a80f52d8086f274dca574043cef93ead Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 11 May 2021 14:22:23 +0800 Subject: [PATCH] =?UTF-8?q?BI-86090=20history=E6=8F=90=E4=BE=9B=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E8=B7=AF=E7=94=B1=E6=98=AF=E5=90=A6=E5=B7=B2=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=9A=84get=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/router.js | 11 +++++++++++ typescript/router/router.ts | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/router/router.js b/src/router/router.js index e22b4167b..279289fc0 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -498,6 +498,17 @@ this.handlers.unshift({route: route, callback: callback}); }, + // check route is Exist. if exist, return the route + checkRoute: function (route) { + for (var i = 0; i < this.handlers.length; i++) { + if (this.handlers[i].route.toString() === Router.prototype._routeToRegExp(route).toString()) { + return this.handlers[i]; + } + } + + return null; + }, + // remove a route match in routes unRoute: function (route) { var index = _.findIndex(this.handlers, function (handler) { diff --git a/typescript/router/router.ts b/typescript/router/router.ts index dea087262..262c9debe 100644 --- a/typescript/router/router.ts +++ b/typescript/router/router.ts @@ -26,6 +26,8 @@ export declare class History { route(route: string, callback: Function): void; + checkRoute(route: string): { route: string, callback: Function}; + unRoute(route: string): void; checkUrl(e?: Event): void;