前端路由的两种模式:hash和history路由

hash 就是指 url 尾巴后的 # 号以及后面的字符,本身是用来做页面定位的,若做路由的话,原来的锚点功能就不能用了。其次,hash 的传参是基于 url 的,如需传递复杂的数据,会有体积的限制,而 history 模式不仅可以在url里放参数,还可以将数据存放在一个特定的对象中。
所以hash路由一般配套使用:
传送:
router.push({
pathname: '/BrainJuvenileAssessment/AllTestDetails',
query: {
taskDetail: taskDetail,
},
});

接收:
//接受路由参数
const {
taskDetail: { taskTestRecordList },
} = this.props.location.query;

传送:
router.push({
pathname: 'report',
state: {
reportId: report.id,
},
});

接收:
//接受路由参数
const {
reportId
} = this.props.location.state;

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容