通过路由设置把同一个页面应用于两个网址
先在路由设置页面设置不同的type字段:
key='/admin/marketingplan/content/111' onClick={() => this.onJump('/admin/marketingplan/content/222')
DashBoard中的路由设置:
<Route path={`${this.props.match.path}/marketingplan/content/:type`} component={PlanContent} />
再在相应页面的Index中取到type:
componentWillMount() { const { match } = this.props; this.props.changePlanType(match.params.type); }
参见React 获取 url 参数 —— this.props.match
最后在相应页面的reducer写个跟后端一致的常量:
export const PAGE_PLAN_TYPE = { 222: { type: 2, name: '222', }, 111: { type: 1, name: '111', }, };
这样,在saga中取数据就可以根据当前页面的type:
const params = {
plan_type: PAGE_PLAN_TYPE[planType].type,
};
const data = yield call(Api.getContentList, params);

不就是取
浙公网安备 33010602011771号