New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nuke-refresh-control

Package Overview
Dependencies
Maintainers
2
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuke-refresh-control

下拉刷新组件

2.2.17
npm
Version published
Weekly downloads
64
190.91%
Maintainers
2
Weekly downloads
 
Created
Source

RefreshControl

  • category: Components
  • chinese: 含 h5 版本的下拉刷新组件
  • type: 基本

RefreshControl 是一个能够实现下拉刷新的子组件,且父组件只能是 <Scrollview><ListView>

// 完整 demo 请参考 ScrollView 组件的 Demo

//初始 state
constructor() {
  super();
  this.state={
    isRefreshing: false,
    refreshText: '↓ 下拉刷新',
    data:[
        //...省略部分代码
    ]
  }
}

handleRefresh =()=>{
  this.setState({
    isRefreshing: true,
    refreshText: '加载中',
  });
  // mock ajax 此处替换为你的 ajax 请求
  setTimeout(() => {
    this.setState({
      isRefreshing: false,
      data: [
          // data 字段变更
      ],
      refreshText: '↓ 下拉刷新',
    });

  }, 1000);
}
render(){
  return(
    <ScrollView>
      <RefreshControl isRefreshing={this.state.isRefreshing} style={{width:750,height:100}} onRefresh={this.handleRefresh}>
          <Text>{this.state.refreshText}</Text>
      </RefreshControl>
      {/* 此处为你的内容区域 */}
    <ScrollView>
  )
}

API

参数说明类型默认值
isRefreshing是否展示false
onRefreshrefresh 事件Function
style样式,必须声明宽高否则可能无法展示object

Keywords

nuke

FAQs

Package last updated on 26 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts