React Native List列表
来源:互联网 发布:java项目开发实例源码 编辑:程序博客网 时间:2024/05/21 06:27
/** * Sample React Native App * https://github.com/facebook/react-native * @flow */import React, { Component } from 'react';import { AppRegistry, StyleSheet, Text, View} from 'react-native';const Header=require('./header');class FirstRN extends Component { render() { return ( <View style={styles.flex}> <Header></Header> <List title="一线城市楼市退烧 有房源一夜跌价160万"></List> <List title="上海市民称墓地太贵买不起 买房存骨灰"></List> <List title="朝鲜再发视频:摧毁青瓦台 一切化作灰机"></List> <List title="生活大爆炸任务原型都好牛掰"></List> <ImportantNews news={['一线城市楼市退烧 有房源一夜跌价160万', '上海市民称墓地太贵买不起 买房存骨灰', '上海市民称墓地太贵买不起 买房存骨灰', '上海市民称墓地太贵买不起 买房存骨灰上海市民称墓地太贵买不起 买房存骨灰上海市民称墓地太贵买不起 买房存骨灰上海市民称墓地太贵买不起 买房存骨灰', '上海市民称墓地太贵买不起 买房存骨灰上海市民称墓地太贵买不起 买房存骨灰上海市民称墓地太贵买不起 买房存骨灰', '上海市民称墓地太贵买不起 买房存骨灰' ]}> </ImportantNews> </View> ); }}class List extends Component { render() { return ( <View style={styles.list_item}> <Text style={styles.list_item_font}>{this.props.title}</Text> </View> //{this.props.title} 属性的传递 ); }}class ImportantNews extends Component { //方法 show(title) { alert(title); } render() {//渲染的方法 var news = [];//定义数组 for(var i in this.props.news) {//循环 var text = ( <Text onPress={this.show.bind(this, this.props.news[i])} numberOfLines={2} style={styles.news_item} key={i}> {this.props.news[i]} </Text> ); news.push(text);//添加到news数组中 } return( <View style={styles.flex}> <Text style={styles.news_title}>今日要闻</Text> {news} </View> ); }}const styles = StyleSheet.create({ flex: { flex: 1, }, list_item: { height: 40, //高度 marginLeft: 10, //左边距 marginRight:10, //右边距 borderBottomWidth: 1, //底部边框 borderBottomColor: '#ddd', //底部边框颜色 justifyContent: 'center', //justify-content 用于设置或检索弹性盒子元素在主轴(横轴)方向上的对齐方式。 }, list_item_font: { fontSize: 16, //字体大小 }, news_title: { fontSize: 20, fontWeight: 'bold', color: '#CD1D1C', marginRight: 10, marginLeft: 10, marginTop: 10, }, news_item: { marginLeft: 10, marginRight: 10, fontSize: 15, lineHeight: 40,//line-height 属性设置行间的距离(行高)。注释:不允许使用负值。 borderBottomWidth: 1, //底部边框 borderBottomColor: '#ddd', //底部边框颜色 },});AppRegistry.registerComponent('FirstRN', () => FirstRN);
0 0
- React Native List列表
- react-native城市列表组件
- React Native—列表组件
- React-Native滑动删除react-native-swipe-list-view
- react-native 侧滑组件 react-native-swipe-list-view
- react-native试玩(8)-列表视图
- React Native——电影列表
- react native 列表展示的解决方案
- react native (二)‘电影列表demo’
- react native 带索引的城市列表
- react native 带索引的城市列表
- react native 带索引的城市列表
- react-native的下拉列表Picker
- React-Native基础_5.列表视图ListView
- React Native开源仿QQ微信列表左右滑动删除等功能组件(react-native-swipeout)
- React Native 学习(三)-- 电影列表展示
- React Native 实现类似QQ的侧滑列表效果
- React Native 基础篇 之 ListView 产品列表实现
- FreeRTOS系列第9篇---FreeRTOS任务概述
- 跑Caffe、FCN遇到的问题记录
- linux seq 锁实现
- 国际象棋程序设计(六):局面评估函数
- FreeRTOS系列第10篇---FreeRTOS任务创建和删除
- React Native List列表
- linux下的find文件查找命令与grep文件内容查找命令
- 在VC中用CRT库查找内存泄露
- Java学习总结第二十九天Java泛型应用
- FreeRTOS系列第11篇---FreeRTOS任务控制
- js 对象属性计算名
- 多线程
- RxJava 和 RxAndroid 三(生命周期控制和内存优化)
- MVV-LVA