react.js页面间传值方式

页面中的表格需要跳转页面编辑,同时应该携带唯一标识id:

import { History } from 'react-router';
    edit = (record) => {
        this.props.history.push({
            pathname:'/app/systemManage/EditUser',
            state:{
                id:record.id
            }
        });
    };

编辑页面中在取到id:

    var userId = this.props.location.state.id;

但是在编辑页面刷新的时候会报错,找不到id,所以换成了用localStorage存储id,解决刷新报错。

感觉react.js有专门的方式跳转页面传值,有待学习奋斗...

猜你喜欢

转载自blog.csdn.net/weixin_41813970/article/details/80239772