首页 新闻 会员 周边

react-router中的match怎么用在export default里?

0
悬赏园豆:5 [待解决问题]

我写了 getData.js 用来请求数据,大致结构是这样的:

export let getData = function(serverName, params = {}){
    return function(Component){
        return class anyComponent extends Component {
            ...

            render(){
                return <Component data={this.state.data} {...this.props} />;
            }
        };
    };
};

export default 里使用时,怎么将 match 信息写在实参里?

class PlistInfo extends Component {
    render(){
        let plistId = this.props.match.params.id;

        return <React.Fragment>aaa</React.Fragment>;
    }
}

export default getData('getPlistInfo', {plistId: '563507'})(PlistInfo);

现在 render 中的 plistId 可以取到,怎么用在 getData 参数里?

zanetti的主页 zanetti | 初学一级 | 园豆:128
提问于:2018-11-27 05:43
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册