zoukankan      html  css  js  c++  java
  • 循环一个文章列表

    实现一个循环列表
    第一步代码如下

    /**
     * Sample React Native App
     * https://github.com/facebook/react-native
     *
     * @format
     * @flow
     */
    
    import React, {Component} from 'react';
    import {Platform, StyleSheet, Text, View} from 'react-native';
    
    
    class Email extends Component {
      render(){
        return(
          <View style={styles.container}>
            <Text style={styles.text}>{this.props.name}</Text>
            <Text style={styles.text}>{this.props.url}</Text>
          </View>
          )
      }
    }
    
    export default class App extends Component{
      render(){
        return(
          <Email name="框架研发部" url="www.baidu.com"/>
        )
      }
    }
    
    
    var styles=StyleSheet.create({
     container:{
       flex:1,
       paddingTop:40,
     },
     text:{
       color:'red'
     }
    })
    

    效果如下

    第二步加入数据层
    代码为:

    /**
     * Sample React Native App
     * https://github.com/facebook/react-native
     *
     * @format
     * @flow
     */
    
    import React, {Component} from 'react';
    import {Platform, StyleSheet, Text, View,ScrollView} from 'react-native';
    
    /**
     * Sample React Native App
     * https://github.com/facebook/react-native
     *
     * @format
     * @flow
     */
    class Email extends React.Component {
      render(){
        return(
          <View style={styles.container}>
            <Text style={styles.text,styles.title}>{this.props.title}</Text>
            <Text style={styles.text}>{this.props.author}</Text>
            <Text style={styles.text}>{this.props.time}</Text>
          </View>
          )
      }
    }
    
    export default class App extends React.Component{
      render(){
            var articles = [
            {
                title: "React-Native入门指南",
                author: "vczero",
                time: "2015-06-28"
            },
            {
                title: "为什么世界不一样",
                author: "vczero",
                time: "2015-06-8"
            },
            {
                title: "你来,我就告诉你",
                author: "vczero",
                time: "2015-04-01"
            }
        ];
        return(
          <ScrollView>
            {
              articles.map(function(article){
                return <Email title={article.title} author={article.author} time={article.time}/>
            })
            }
          </ScrollView>
        )
      }
    }
    
    
    var styles=StyleSheet.create({
     container:{
       flex:1,
       paddingTop:20,
       flexDirection:'row'
     },
     text:{
       color:'red'
     },
     title:{
       color:'blue'
     }
    })
     
    

    效果如下

  • 相关阅读:
    AUDIT审计的一些使用
    HOW TO PERFORM BLOCK MEDIA RECOVERY (BMR) WHEN BACKUPS ARE NOT TAKEN BY RMAN. (Doc ID 342972.1)
    使用BBED理解和修改Oracle数据块
    Using Class of Secure Transport (COST) to Restrict Instance Registration in Oracle RAC [ID 1340831.1]
    调试利器GDB概念
    第4章 思科IOS
    第3章 ip地址和子网划分
    第2章 TCPIP
    2020年阅读过的黑客资源推荐篇
    第1章 计算机网络
  • 原文地址:https://www.cnblogs.com/smart-girl/p/10655146.html
Copyright © 2011-2022 走看看