发布于 2018-10-09 18:08:32
然后,可以使用outlet高阶组件使用这些Outlet标识符来配置
Dojo2小部件。Outlet返回一个新的小部件,它可以像渲染方法中的任何其他小部件一样使用,例如w(MyFooOutlet,{ })
映射参数
当为出口配置小部件时,可以提供一个回调函数,用于注入在小部件的呈现生命周期中可用的属性。
mapParams(type: 'error | index | main', location: string, params: {[key: string]: any}, router: Router)以下示例使用mapParams注入onClose函数,该函数将转到根据other-outlet路由和从MyViewWidget属性中的参数提取的id属性注册的路由:
const mapParams = (options: MapParamsOptions) {
const { type, params, router } = options;
return {
onClose() {
// This creates a link for another outlet and sets the path
router.setPath(router.link('other-outlet'));
},
id: params.id
}
}
const FooOutlet = Outlet(MyViewWidget, 'foo', { mapParams });https://stackoverflow.com/questions/51665602
复制相似问题