我正在尝试在react-router-dom Link中传递参数,但不确定为什么它每次都不起作用。有时工作正常,有时单击时什么也没有发生(devtool中没有错误)。我首先导入了Link,从“ react-router-dom”中导入了{Link};谁能帮我吗?谢谢。
constructor(props){
super(props);
this.state = {
pageNumber: 1,
pageSize: 10,
keyWork:"",
// modal: cancel notification
visible:false,
doctorID:"",
// table header
columns:[
{title:"Doctor Photo", dataIndex:"picUrl", key:"picUrlMenu", width:70, fixed: 'left',
render: picUrl => <Image className="doctorPhoto" style={{ height: 50, width:50 }} alt={picUrl} src={picUrl}/>
},
{title:"DoctorID", dataIndex:"doctorID", key:"doctorIdMenu", width:70, fixed: 'left',responsive: ['md'],
defaultSortOrder: 'descend',
sorter: (a, b) => a.doctorID - b.doctorID,
},
{title:"Management", dataIndex:"management", key:"management", width:200, fixed: 'right',
render:(text, rowData) =>{
return(
<div>
<Button className="planButton" type="primary" icon={<SnippetsOutlined />}>
<Link
to={{
pathname: "/index/plan",
state:{doctorid: rowData.doctorID}}}>,
</Link>
Plan
</Button>
<Popover content={content} >
<Button className="delDoctorButton" icon={<DeleteOutlined />} onClick={()=>this.delDoctor(rowData.doctorID)} >Delete</Button>
</Popover>
</div>
)
}
}
],
// tabel data
data:[],
};
}
最后,我发现代码没有问题,现在链接仅在单击文本“计划”时有效,因此,如果要在单击按钮时重定向,只需将链接移至按钮,如下所示:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句