-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
import React from 'react'; | ||
import { connect } from 'dva'; | ||
import { Table, Pagination, Popconfirm } from 'antd'; | ||
import { routerRedux } from 'dva/router'; | ||
import styles from './Users.css'; | ||
import { PAGE_SIZE } from '../../constants'; | ||
|
||
function Users({ list: dataSource, loading, total, page: current }) { | ||
function Users({ dispatch, list: dataSource, loading, total, page: current }) { | ||
function deleteHandler(id) { | ||
console.warn(`TODO: ${id}`); | ||
} | ||
|
||
function pageChangeHandler(page) { | ||
dispatch(routerRedux.push({ | ||
This comment has been minimized.
Sorry, something went wrong.
LL-wzl
|
||
pathname: '/users', | ||
query: { page }, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lucasyue
|
||
})); | ||
} | ||
|
||
const columns = [ | ||
{ | ||
title: 'Name', | ||
|
@@ -55,6 +63,7 @@ function Users({ list: dataSource, loading, total, page: current }) { | |
total={total} | ||
current={current} | ||
pageSize={PAGE_SIZE} | ||
onChange={pageChangeHandler} | ||
/> | ||
</div> | ||
</div> | ||
|
8 comments
on commit b6203ea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果数据为空的话,页码没有隐藏,而是有5页,然后有个NaN,请问怎么解决?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在models/users.js中effets的fetch方法中有如下代码:
total: parseInt(headers['x-total-count'], 10),
page: parseInt(page, 10),
默认值是10,所以才会出现5页
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
后面添加了删除功能后只是能够响应,并不能真正在界面上去掉数据,有什么思路呢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
从加入page开始就一直报这个错误:
Error: TypeError: Cannot read property 'page' of undefined.
导致查不出信息,
你们有遇到过吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dreampasssser 你应该用的 dva 2.0 版本,dva 2.0 不是这么写了。
sorrycc/blog#18 上面有写 注:本文仅适用于 dva@1,尚未适配到 dva@2 。
想知道具体的写法,可以参考:https://github.com/dvajs/dva-example-user-dashboard 代码
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hangyangws 确实用的dva2.x版本,没注意到那句话,谢谢啦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
点击分页报了个错:Warning: Hash history cannot PUSH the same path; a new entry will not be added to the history stack,有人遇到过吗? "dva": "^2.1.0",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
点击分页报了个错:Warning: Hash history cannot PUSH the same path; a new entry will not be added to the history stack,有人遇到过吗? "dva": "^2.1.0",
同样的报错
This comment has been minimized.
Sorry, something went wrong.
nsueduMay 15, 2018