react 中文文档案例五 (循环列表)
- function NumberList(props) {
- const numbers = props.numbers;
- const listItems = numbers.map((number) =>
- <li key={number.toString()}>
- {number}
- </li>
- );
- return (
- <ul>{listItems}</ul>
- );
- }
- const numbers = [, , , , ];
- ReactDOM.render(
- <NumberList numbers={numbers} />,
- document.getElementById('root')
- );
- //key值最好选用id,没有稳定的id的时候选择index
- const todoItems = todos.map((todo) =>
- <li key={todo.id/index}>
- {todo.text}
- </li>
- );
- function Blog(props) {
- const sidebar = (
- <ul>
- {props.posts.map((post) =>
- <li key={post.id}>
- {post.title}
- </li>
- )}
- </ul>
- );
- const content = props.posts.map((post) =>
- <div key={post.id}>
- <h3>{post.title}</h3>
- <p>{post.content}</p>
- </div>
- );
- return (
- <div>
- {sidebar}
- <hr />
- {content}
- </div>
- );
- }
- const posts = [
- {id: , title: 'Hello World', content: 'Welcome to learning React!'},
- {id: , title: 'Installation', content: 'You can install React from npm.'}
- ];
- ReactDOM.render(
- <Blog posts={posts} />,
- document.getElementById('root')
- );
react 中文文档案例五 (循环列表)的更多相关文章
- react 中文文档案例三 (开关按钮)
开关按钮制作 import React from 'react'; import ReactDOM from 'react-dom'; class Toggle extends React.Com ...
- react 中文文档案例七 (温度计)
const scaleNames = { c: 'Celsius', f: 'Fahrenheit' }; function toCelsius(fahrenheit) { ) * / ; } fun ...
- react 中文文档案例六 (表单)
class Reservation extends React.Component { constructor(props) { super(props); this.state = { isGoin ...
- react 中文文档案例四 (登陆登出按钮)
import React from 'react'; import ReactDOM from 'react-dom'; class LoginControl extends React.Compon ...
- react 中文文档案例二 (头像时间)
import React from 'react'; import ReactDOM from 'react-dom'; function formatDate(date) { return date ...
- react 中文文档案例一 (倒计时)
1.函数试组件 import React from 'react'; import ReactDOM from 'react-dom'; function Clock(props){ return( ...
- phpspreadsheet 中文文档(五)节约内存+PHPExcel迁移
2019年10月11日14:03:31 节省内存 PhpSpreadsheet在工作表中平均每个单元格使用约1k,因此大型工作簿可以迅速用尽可用内存.单元缓存提供了一种机制,使PhpSpreadshe ...
- ASP.NET Core 中文文档 第五章 测试(5.2)集成测试
原文: Integration Testing 作者: Steve Smith 翻译: 王健 校对: 孟帅洋(书缘) 集成测试确保应用程序的组件组装在一起时正常工作. ASP.NET Core支持使用 ...
- talib 中文文档(五):文档导航
Documentation 安装和问题 快速使用 高级应用 方法分类 Overlap Studies 重叠的研究 Momentum Indicators 动量指标 Volume Indicators ...
随机推荐
- 部署和调优 2.9 mysql主从配置-3
测试 先给主mysql解锁 > unlock tables; 删除一个表 > use db1; > show tables; > drop table help_categor ...
- AudioFormat
AudioFormat 用于访问 一系列语音格式和通道配置常量 例如用于AudioTrack 和AudioRecord中 The AudioFormat class is used to acce ...
- springmvc 路径问题
web项目中的相对路径可以分为二类: 1.以斜杠开头:以斜杠开头的又分为二类(分类依据是斜杠出现的位置):如果出现在java代码或者配置文件(xml,properties等),这个路径叫做后台路径. ...
- sharepoint文档库中日期显示详细日期,不显示几天前
文档库---库设置----栏
- java中用正则表达式判断中文字符串中是否含有英文或者数字
public static boolean includingNUM(String str)throws Exception{ Pattern p = Pattern.compile(" ...
- SWT简介
--------------siwuxie095 SWT 简介: SWT(Standard Widget Toolkit) 也是基于一个对等体实 ...
- ROS Learning-004 beginner_Tutorials 介绍简单的ROS命令
ROS Indigo beginner_Tutorials-03 介绍简单的ROS命令 我使用的虚拟机软件:VMware Workstation 11 使用的Ubuntu系统:Ubuntu 14.04 ...
- Paxos在大型系统中的应用场景
https://timyang.net/distributed/paxos-scenarios/ 在分布式算法领域,有位非常重要的短发叫Paxos,它的重要性有多高呢?Google的Chubby[1] ...
- android自定义视图属性(atts.xml,TypedArray)学习
是一个用于存放恢复obtainStyledAttributes(AttributeSet, int[], int, int)或 obtainAttributes(AttributeSet, int[] ...
- TinkerPop中的遍历:图的遍历中谓词、栅栏、范围和Lambda的说明
关于谓词的注意事项 P是Function<Object,Boolean>形式的谓词.也就是说,给定一些对象,返回true或false.所提供的谓词在下表中概述,并用于各种步骤,例如has( ...