function withStoreHistory(storeName) {
if (!storeName) return console.error(`必须输入一个查询数据的store`);
return function(Target) {
class WithStoreHistory extends Component {
componentDidMount() {
const { history } = this.props;
const store = this.props[storeName];
store.history = history;
}
render() {
return <Target {...this.props} />;
}
}
return WithStoreHistory;
};
}
使用
const MERCHANTSTORE = "merchantStore";
@inject(MERCHANTSTORE)
@withStoreHistory(MERCHANTSTORE)
@observer
class BusinessEntrance extends Component {
render() {
return (
<div>...</div>
);
}
}
函数中使用
@action.bound
handleSettingData() {
this.history.push("/merchants_settled");
}