简体   繁体   English

如何从DOJO2中的URL获取参数

[英]How to get parameter from URL in DOJO2

I have a URL: http://app/material/id/58 我有一个网址: http:// app / material / id / 58

I want to get the id '58' on another widget but I am not able to splice the value. 我想在另一个小部件上获取ID'58',但无法拼接该值。

Any suggestions? 有什么建议么?

Dojo 2 Widgets can then be configured with these outlet identifiers using the Outlet higher order component. 然后,可以使用Outlet高阶组件使用这些出口标识符配置Dojo 2 Widget。 Outlet returns a new widget that can be used like any other widget within a render method, eg w(MyFooOutlet, { }) Outlet返回一个新的窗口小部件,可以像渲染方法中的任何其他窗口小部件一样使用它,例如w(MyFooOutlet,{})

Map Parameters : 地图参数

When a widget is configured for an outlet it is possible to provide a callback function that is used to inject properties that will be available during render lifecycle of the widget. 将小部件配置为插座时,可以提供一个回调函数,该函数用于注入在小部件的渲染生命周期中可用的属性。

mapParams(type: 'error | index | main', location: string, params: {[key: string]: any}, router: Router)

The following example uses mapParams to inject an onClose function that will go to the route registered against the other-outlet route and id property extracted from params in the MyViewWidget properties: 以下示例使用mapParams注入一个onClose函数,该函数将转到针对从MyViewWidget属性的参数中提取的other-outlet路由和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 });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM