Lobos / react-ui

A collection of components for React, base on bootstrap 4.0.
http://lobos.github.io/react-ui/
MIT License
1.63k stars 302 forks source link

table中pagination中的onChange问题 #114

Closed zhangqhzz closed 6 years ago

zhangqhzz commented 6 years ago

pagination={
size: int,
page: int,
total: int,
range: int,
onChange(int),
position: 'string'
} onChange这个如何给定? 我在构造器内声明绑定了pageChange,然后在pagination={ size:10,onChange:this.pageChange}时,提示Unable to get property 'bind' of undefined or null reference

Lobos commented 6 years ago

这个看起来像是 constructor 里面绑定 pageChange 的问题。检查一下看看呢。

zhangqhzz commented 6 years ago

constructor 里面 this.pageChange = this.pageChange.bind(this)

zhangqhzz commented 6 years ago

给个试过的在table的pagination中用onChange的例子,总感觉哪个地方有问题

Lobos commented 6 years ago

看下这个呢,不过这个是用路由来处理的,其实差不多。

zhangqhzz commented 6 years ago

onChange中要处理的内容不一样,我是要进行this.setState

zhangqhzz commented 6 years ago

我的pagechange(page,sidx,sord){ if(sidx===undefined){ this.setState({page:page}) }else{ this.setState({page:page,sidx:sidx,sord:sidx}) } } onChange:应该如何写?

zhangqhzz commented 6 years ago

onChange:(page,sidx,sord)=>this.pageChange.bind(this,page,sidx,sord) 这样可以吗?

zhangqhzz commented 6 years ago

其他部分不用管,我有做部分js文件的修改

Lobos commented 6 years ago

https://github.com/Lobos/qenya/blob/master/frontend/components/Schema/Data/index.js

Lobos commented 6 years ago

pagechange(page,sidx,sord){ if(sidx===undefined){ this.setState({page:page}) }else{ this.setState({page:page,sidx:sidx,sord:sidx}) } }

这段是copy出来的代码?好像pagechange 名称和 bind 那里的不一致,Change 没大写

zhangqhzz commented 6 years ago

这个例子<Pagination 是单独在用,不是Table中的属性pagination在用

zhangqhzz commented 6 years ago

谢谢,是哦,没大写

zhangqhzz commented 6 years ago

谢谢,好了,晕,大小写搞死了,您的控件很好,我在学习,为我的需要作相应修改,再次表示感谢