这两天在学习dva,在看 https://github.com/zuiidea/antd-admin的代码。有一个疑问,想问问大家。
https://github.com/zuiidea/antd-admin/blob/master/src/routes/users/index.js
const userListProps = {
dataSource: list,
loading,
pagination,
location,
isMotion,
onPageChange (page) {
**console.log({
...query,
page: page.current,
pageSize: page.pageSize,
})** //这里输出 为: Object {page: 1, pageSize: 10}
const { query, pathname } = location
dispatch(routerRedux.push({
pathname,
query: {
...query,
page: page.current,
pageSize: page.pageSize,
current :page.current
},
}))
},
}
https://github.com/zuiidea/antd-admin/blob/master/src/models/users.js
effects: {
*query ({ payload }, { call, put }) {
**console.log("payload ", payload)** //这里输出 为: Object { page: "1", pageSize: "10"}
const data = yield call(query, parse(payload))
var page = {
total: data.body.total ,
current: parseInt(payload.page,10) //如果传递过来的数据类型没变的话,我这里也不用转换类型了。
}
if (data) {
yield put({
type: 'querySuccess',
payload: {
list: data.body.users,
pagination:page,
},
})
}
},
我就是不太明白,为什么数据类型会被改变了。