RN_ScrollView
RN_ScrollView模块1:myScrollView实现ScrollowView的基本功能 index.ios.jsvar RN_ScrollView = require("./movieList"); myScrollView:头文件import React,{ Component } from 'react'; import { AppRegistry,StyleSheet,Text,View,ScrollView,RefreshControl,} from 'react-native'; myScrollView:组件ScrollowView 的简单实现 检测拖拽以及还拽的相关方法 并且添加几个子组件 var MyScrollView = React.createClass({ _onScrollBeginDrag:function () { console.log("start drag 001"); },_onScrollEndDrag:function () { console.log("end drag 002 "); },_onMomentumScrollBegin:function () { console.log("start move 003"); },_onMomentumScrollEnd:function () { console.log("end move 004"); },_onRefresh:function () { console.log("刷新。。。"); },render:function () { return( <View style = {styles.container}> <ScrollView style = { styles.scrollowView} showsVerticalScrollIndicator = {true} onScrollBeginDrag = {this._onScrollBeginDrag} onScrollEndDrag = {this._onScrollEndDrag} onMomentumScrollBegin = {this._onMomentumScrollBegin} onMomentumScrollEnd = {this._onMomentumScrollEnd} refreshControl = { <RefreshControl refreshing = {false} tintColor = "gray" title = "正在刷新..." onRefresh = {this._onRefresh} /> } > <View style = {styles.view_1}></View> <View style = {styles.view_2}></View> <View style = {styles.view_3}></View> </ScrollView> </View> ); },}); myScrollView:样式var styles = StyleSheet.create({ container:{ flex:1,backgroundColor:"cyan",},scrollowView:{ marginTop:25,backgroundColor:"#CCCCCC",view_1:{ margin:15,flex:1,height:300,backgroundColor:"yellow",view_2:{ margin:15,backgroundColor:"red",view_3:{ margin:15,backgroundColor:"black",}); 导出module.exports = MyScrollView; 模块2:电影列表 index.ios.jsar RN_ScrollView = require("./movieList"); movieList.js:头文件import React,Image,} from 'react-native'; movieList.js:组件/*数据源 才用本地数据 JSON数据 网址址https://raw.githubusercontent...
var movieData = require("./data.json"); var movies = movieData.movies; var MovieList = React.createClass({ render :function () { var moviesRows = []; for(var i in movies){ var movie = movies[i]; var row = ( <View key = {i} style = {styles.row}> <Image source = {{uri:movie.posters.thumbnail}} style ={styles.thumbnail} ></Image> <View style = {styles.rightContainer}> <Text style = {styles.title}>{movie.title}</Text> <Text style = {styles.year}>{movie.year}</Text> </View> </View> ); moviesRows.push(row); } return ( <View style ={styles.container}> <ScrollView style ={styles.scrollView}> { moviesRows } </ScrollView> </View> ); },}); movieList.js:样式var styles = StyleSheet.create({ container:{ flex:1,scrollView:{ flex:1,marginTop:25,backgroundColor:"#F5FCFF",row:{ flexDirection:"row",padding:5,alignItems:"center",thumbnail:{ width:53,height:81,rightContainer:{ marginLeft:10,title:{ fontSize:18,marginTop:3,marginBottom:3,textAlign:"center",year:{ marginBottom:3,}); 导出module.exports = MovieList; RN官网(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |