本文整理匯總了TypeScript中mithril/route.route函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript route函數的具體用法?TypeScript route怎麽用?TypeScript route使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了route函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: route
route(document.body, '/', {
'/': component1,
'/test1': {
onmatch(args, path) {
return component1;
}
},
'/test2': {
render(vnode) {
return h(component1);
}
},
test3: {
onmatch(args, path) {
return component2;
},
render(vnode) {
return ['abc', 123, null, h(component2), ['nested', h('p', 123)]];
}
},
test4: {
onmatch(args, path) {
// Must provide a Promise type if we want type checking
return new Promise<Component<{title: string}, {}>>((resolve, reject) => {
resolve(component2);
});
}
},
'test5/:id': routeResolver
});
示例2: route
route(document.body, '/', {
'/': component1,
'/test1': {
onmatch(args, path) {
return component1;
}
},
'/test2': {
render(vnode) {
return h(component1);
}
},
test3: {
onmatch(args, path) {
return component2;
},
render(vnode) {
return ['abc', 123, null, h(component2), ['nested', h('p', 123)]];
}
},
test4: {
onmatch(args, path) {
// Must provide a Promise type if we want type checking
return new Promise<Component<{title: string}, {}>>((resolve, reject) => {
resolve(component2);
});
}
},
'test5/:id': routeResolver,
test6: {
onmatch(args, path) {
// Can return ClassComponent from onmatch
return Component4;
}
},
test7: {
onmatch(args, path) {
// Can return FactoryComponent from onmatch
return component5;
}
},
// Can use other component types for routes
test8: Component4,
test9: component5
});