Router
Direct Subclass:
Router
This subclass must override depart() and go(path)
Example:
const routeMap = {
index: HomeView, // /
about: AboutView, // /about
books: {
index: BookListView, // /books/
':bookId': {
index: BookDetailView, // /books/:bookId
summary: BookSummaryView, // /books/:bookId/summary
readers: {
index: '../', // redirect to /books/:bookId
':readerId': BookReaderView // /books/:bookId/readers/:readerId
}
},
pages: {
index: PagesView, // /pages/
faq: FaqView, // /pages/faq
policy: PolicyView // /pages/policy
}
};
const router = new Router(routeMap);
Constructor Summary
Public Constructor | ||
public |
|
Member Summary
Public Members | ||
public |
onMove: * |
Private Members | ||
private |
_lastRoute: * |
|
private |
_routeTree: * |
Method Summary
Public Methods | ||
public |
canGo(path: *): * Need call |
|
public |
|
|
public |
Need call |
Private Methods | ||
private |
_chopEndSlash(pt: *): * |
|
private |
_isStr(v: *): * |
|
private |
_parsePath(path: *): * |
|
private |
_parseRoute(map: *): * |
|
private |
_resolve(src: *, dest: *): * |
Public Constructors
public constructor() source
Public Members
public onMove: * source
Private Members
private _lastRoute: * source
private _routeTree: * source
Public Methods
public canGo(path: *): * source
Need call depart
after first page loaded
depart() { }
Params:
Name | Type | Attribute | Description |
path | * |
Return:
* |
public move(path: String) source
Need call go
when History mode and anchor tag clicked
or moving the other page by a script
Params:
Name | Type | Attribute | Description |
path | String | path go(path) { } |
Private Methods
private _resolve(src: *, dest: *): * source
Params:
Name | Type | Attribute | Description |
src | * | ||
dest | * |
Return:
* |