如何在reactjs

时间:2017-06-26 10:58:35

标签: javascript reactjs react-router

我必须在我的路线中插入2个ID,我必须在我的数据库中插入这两个,但第一个path.id未定义

enter image description here

这里的path.id是未定义的

const {params} = this.context.router;
    const {router} = this.context;
    const {routes} = router;
    let {path} = routes[routes.length - 1];
    let {form} = this.props.timeline;

    form.TimelineKey = (params.id);
    form.Link = path.id+ "/" + params.id ;

我不知道如何获得1068.这是我在调试器中发生的情况:

enter image description here

1 个答案:

答案 0 :(得分:0)

所有react-router参数都可以在this.props.params下找到。

根据评论中提供的信息,您可以获得timeline参数,如下所示:

this.props.params.timeline

所以你可以这样做:

form.Link = this.props.params.timeline + "/" + this.context.router.id ;