RefreshControl 下拉刷新
定义/Definition
用于需要下拉刷新的场景
规则 / Rule
用于需要下拉刷新的场景
代码演示
基本
下拉刷新
import { RefreshControl } from 'antd-mobile';let count = 1;const App = React.createClass({ getInitialState() { return { items: [ <div key={`item-${count}`} style={{ height: 70 }}>条目 {count++}</div>, ], }; }, loadingFunction() { return new Promise((resolve, reject) => { setTimeout(() => { if (this.addItem()) { resolve(); } else { reject(); } }, 500); }); }, addItem() { this.state.items.push(<div key={`item-${count}`} style={{ height: 70 }}>条目 {count++}</div>); this.setState({ items: this.state.items, }); return true; }, render() { return ( <RefreshControl loadingFunction={this.loadingFunction} distanceToRefresh={60} resistance={1} style={{ position: 'relative', paddingTop: 20, textAlign: 'center', }} hammerOptions={{ touchAction: 'auto', recognizers: { pan: { threshold: 10, }, }, }} > <h3>下拉刷新</h3> <div style={{ minHeight: 300 }}> {this.state.items} </div> </RefreshControl> ); },});ReactDOM.render(<App />, mountNode);

API (web)
| 成员 | 说明 | 类型 | 默认值 |
|---|
| children | 内容 | any | 无 |
| contentClassName | 内容容器className | String | - |
| contentStyle | 内容容器style | object | - |
| icon | 刷新指示icon | React element | … |
| loading | 加载指示器 | React element | anticon-loading |
| distanceToRefresh | 刷新距离 | number | 70 |
| resistance | 阻力系数 | number | 2.5 |
| loadingFunction | 刷新回调函数 | function, required | - |
| hammerOptions | 参考 react-hammerjs ,用于配置 Hammer manager,将被合并到默认配置中 | object | - |
API (ios/android)
见此:https://facebook.github.io/react-native/docs/refreshcontrol.html#props