Reactjs 如何在antd的分页上向该事件添加参数?
型号: 路线:Reactjs 如何在antd的分页上向该事件添加参数?,reactjs,redux,react-redux,antd,Reactjs,Redux,React Redux,Antd,型号: 路线: import { getNewslList } from '../services/home'; export default { namespace: 'newslist', state:{ list: [], total: null, pageSize: null, currentPage: null, id: null }, reducers: { query(state, { payload: { list,
import { getNewslList } from '../services/home';
export default {
namespace: 'newslist',
state:{
list: [],
total: null,
pageSize: null,
currentPage: null,
id: null
},
reducers: {
query(state, { payload: { list, total, pageSize, currentPage, id } }) {
return { ...state, list, total, pageSize, currentPage, id };
},
},
effects: {
*fetch({ payload: { id , p = 1 } }, {call, put}) {
// const cid = id;
const { data } = yield call(getNewslList, id, p );
yield put({
type: 'query',
payload:{
list: data.Result.Data,
total: parseInt(data.Result.TotalCount, 10),
pageSize: parseInt(data.Result.PageSize, 10),
currentPage: parseInt(data.Result.PageIndex, 10),
id: id,
}
});
},
},
subscriptions: {
setup({ dispatch, history }) {
return history.listen(({ pathname, query }) => {
if (pathname === '/news') {
dispatch({ type: 'fetch', payload: query });
}
});
},
},
}
如何操作?将您的pageChangeHandler更改为:
function pageChangeHandler(p) {
dispatch(routerRedux.push({
pathname: '/news',
query: { p },
}));
}
然后像这样使用它:
function pageChangeHandler(id, p) {
dispatch(routerRedux.push({
pathname: '/news',
query: { id, p },
}));
}
function pageChangeHandler(id, p) {
dispatch(routerRedux.push({
pathname: '/news',
query: { id, p },
}));
}
pageChangeHandler.bind(id)