react 通过 state 传参以后,清除 state 缓存
场景:
react 通过 state 实现页面间的传值,当用户点击重置按钮的时候,需要清除 state 里面的数据,否则,用户刷新页面,请求列表数据时,还会带上 state 里面的参数,导致数据不准
思路:
通过 history.replace 实现
方案:
<Table
dataSet={ds}
columns={columns}
queryBarProps={{
onReset: () => {
history.replace({
...history.location,
state: {
...history.location.state,
propertyId: null,
propertyName: null,
propertyCode: null,
}
});
ds.queryDataSet.reset();
},
}}
/>
.

浙公网安备 33010602011771号