我必须在我的路线中插入2个ID,我必须在我的数据库中插入这两个,但第一个path.id
未定义
这里的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.这是我在调试器中发生的情况:
答案 0 :(得分:0)
所有react-router参数都可以在this.props.params
下找到。
根据评论中提供的信息,您可以获得timeline
参数,如下所示:
this.props.params.timeline
所以你可以这样做:
form.Link = this.props.params.timeline + "/" + this.context.router.id ;