antd-mobile中listView遇到的坑
来源:互联网 发布:红楼梦87版细节知乎 编辑:程序博客网 时间:2024/05/29 04:42
在dataSourse中设置了很多数据,即使是本地静态的数据,页面上也只显示10条?
listView默认把数据放在页面上10条,如果10条数据在页面显示高度不高过容器,就不会刷新,再次更新
import React from 'react'import {Flex, ListView} from '../../component'const {Component, PropTypes} = React// 虚拟数据const dataItem = { img: 'https://zos.alipayobjects.com/rmsportal/dKbkpPXKfvZzWCM.png', title: 'Meet hotel', des: '不是所有的兼职汪都需要风吹日晒',}const data = []for (let i = 0; i < 100; i++) { dataItem.key = i data.push(dataItem)}class Bargain extends Component { constructor (props) { super(props) const dataSource = new ListView.DataSource({ rowHasChanged: (row1, row2) => row1 !== row2, }) this.state = { dataSource: dataSource.cloneWithRows({}), isLoading: true, } } componentDidMount () { this.setState({ dataSource: this.state.dataSource.cloneWithRows(data), isLoading: false, }) } static propTypes = { dispatch: PropTypes.func } renderList() { const row = (dataRow) => { return ( <Flex style={{height: 200}}> <p>{dataRow.title}</p> {dataRow.des} </Flex> ) } return ( <ListView style={{ height: document.documentElement.clientHeight, overflow: 'auto', }} dataSource={this.state.dataSource} renderFooter={() => (<div style={{padding: 30, textAlign: 'center'}}> {this.state.isLoading ? '加载中' : '加载完成'} </div>)} renderRow={row} pageSize={4} scrollRenderAheadDistance={500} scrollEventThrottle={20} onEndReachedThreshold={10} /> ) } render () { return ( <div className='bargain-container' > {data.length === 0 ? (<h1>暂时没有商品</h1>) : this.renderList()} </div> ) }}export default Bargain
阅读全文
0 0
- antd-mobile中listView遇到的坑
- 使用antd-mobile遇到的坑
- 在react-native中引入antd-mobile遇到的问题
- antd-mobile
- webpack+react+antd项目编写过程中遇到的问题
- antd mobile(十二) dva中使用mockJs
- react项目的组件库antd-mobile
- webpack react antd遇到的问题
- antd mobile(九) iscroll5集成到项目中
- antd mobile(十一) MeScroll集成到项目中
- react中安装antd-mobile时出现错误
- android中Listview+GridView遇到的坑
- antd mobile(十) 性能优化PureRender的使用
- JQuery Mobile开发中遇到的问题
- ListView遇到的坑
- ES5中引入antd表格的使用
- antd mobile(一) 环境搭建
- antd mobile(七) 固定NavBar
- 学习笔记--Windows修改emacs文件路径
- Flexbox布局(CSS3 弹性布局,Flexible Box)之 基本概念解析
- Linux & Windows 修改python的pip源
- 修改request中header的值
- 在visual studio2015 C++下配置halcon环境一劳永逸的方法
- antd-mobile中listView遇到的坑
- javascript中的window.location.search和match
- 解读 CSS 布局之水平垂直居中
- DECLARE_MESSAGE_MAP()/BEGIN_MESSAGE_MAP()用法
- MySQL与Oracle数据类型对照表
- ubuntu16.04+caffe 安装可能遇到的坑
- CSS:谈谈栅格布局
- OpenJudge 3531 判断整除
- 打开EXCEL运行脚本,报无法运行宏问题