首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

RefreshControl

该组件在ScrollView或ListView中用于添加拉取功能。当ScrollView在scrollY: 0,向下滑动触发一个onRefresh事件。

用法示例

代码语言:javascript
复制
class RefreshableList extends Component {
  constructor(props) {
    super(props);
    this.state = {
      refreshing: false,
    };
  }

  _onRefresh() {
    this.setState({refreshing: true});
    fetchData().then(() => {
      this.setState({refreshing: false});
    });
  }

  render() {
    return (
      <ListView
        refreshControl={
          <RefreshControl
            refreshing={this.state.refreshing}
            onRefresh={this._onRefresh.bind(this)}
          />
        }
        ...
      >
      ...
      </ListView>
    );
  }
  ...
}

注意: refreshing是一个受控的道具,这就是为什么它需要在onRefresh功能中设置为true,否则刷新指示灯将立即停止。

道具

ViewPropTypes props...

onRefresh?: function

当视图开始刷新时调用。

refreshing: bool

视图是否应该指示主动刷新。

androidcolors?: [color]

将用于绘制刷新指示符的颜色(至少一个)。

androidenabled?: bool

是否启用拉动刷新功能。

androidprogressBackgroundColor?: color

刷新指示器的背景颜色。

androidprogressViewOffset?: number

进度视图顶部偏移量

androidsize?: enum(RefreshLayoutConsts.SIZE.DEFAULT, RefreshLayoutConsts.SIZE.LARGE)

刷新指示符的大小,请参阅RefreshControl.SIZE。

iostintColor?: color

刷新指示器的颜色。

iostitle?: string

标题显示在刷新指示器下。

iostitleColor?: color

标题颜色。

扫码关注腾讯云开发者

领取腾讯云代金券