本文整理汇总了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
});