【发布时间】:2020-04-07 19:11:28
【问题描述】:
我正在尝试使用按钮单击事件中的历史对象将查询字符串参数发送到另一个页面,如下所示
const viewChange = (record) => {
debugger;
history.push('/Viewchange?id=record.id&dataid=record.dataid');
};
这是我在 routes.js 文件中定义的路线
{
path: '/Viewchange/:id/:dataid',
exact: true,
title: 'Viewchange',
icon: 'dashboard',
breadcrumbs: ['dashboard'],
contentComponent: ViewChangeRequest,
isEnabled: () => false,
},
我如何得到一个带有下面网址的空页面
http://localhost:3000/Viewchange?id=record.id&dataid=record.dataid#
我不确定在这种情况下我做错了什么,谁能告诉我如何将查询字符串值附加到 url 下面的代码是我要重定向的组件
const ViewChangeRequest = (props) => {
};
export default withRouter(ViewChangeRequest);
提前多谢
完整的 route.js 代码
[
{
path: '/',
exact: true,
title: 'Dashboard',
icon: 'dashboard',
breadcrumbs: ['Dashboard'],
contentComponent: UserDashboard,
isEnabled: () => true,
},
{
type: 'subMenu',
title: 'Codes and Guidelines',
children: [
{
path: '/LocalCodes',
exact: true,
title: 'Local Codes',
icon: 'dashboard',
breadcrumbs: ['Codes and Guidelines', 'Local Codes'],
contentComponent: AddLocalCode,
isEnabled: () => true,
},
],
},
{
type: 'subMenu',
title: 'Design Criteria',
children: [
{
path: '/Climate',
exact: true,
title: 'Climate',
icon: 'dashboard',
breadcrumbs: ['Design Criteria', 'Climate'],
contentComponent: ContentClimate,
isEnabled: () => true,
},
],
},
{
path: '/Viewchange/:id/:dataid',
title: 'Viewchange',
icon: 'dashboard',
breadcrumbs: ['dashboard'],
contentComponent: ViewChangeRequest,
isEnabled: () => false,
},
];
【问题讨论】:
标签: javascript reactjs react-router router