each

处理warning:Each child in a list should have a unique “key” prop.

≯℡__Kan透↙ 提交于 2020-02-26 10:57:25
问题: 使用react在循环生成多个组件的时候经常会报一个警告: Each child in a list should have a unique “key” prop 原因: 这是由于在进行组件遍历的时候没有加一个key来进行区分每个组件,因为dom需要deff进行对比 解决方案: 如果是进行循环遍历生成组件的,将key设置为index即可 Html = ( ) => { const data = [ 3 , 6 , 9 , 12 , 24 , 36 ] ; const html = [ ] ; data . forEach ( ( item , index ) => { html . push ( // 生成组件时带上key值 < div className = { styles . productWrap } key = { index } > < div className = { styles . leftLable } > { item } 期: < / div > < InputNumber / > < / div > ) ; } ) ; return html ; }; ``` 如果不是遍历生成的组件的话,state中声明一个初始值为0的idKey,然后每次生成一次组件的时候将idkey进行加一处理 来源: CSDN 作者: 蓝枫秋千 链接: https:/

CF 1131A,1131B,1131C,1131D,1131F(Round541 A,B,C,D,F)题解

Deadly 提交于 2020-02-26 03:50:33
A. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In order to make the "Sea Battle" game more interesting, Boris decided to add a new ship type to it. The ship consists of two rectangles. The first rectangle has a width of w 1 w1 and a height of h 1 h1, while the second rectangle has a width of w 2 w2 and a height of h 2 h2, where w 1 ≥ w 2 w1≥w2. In this game, exactly one ship is used, made up of two rectangles. There are no other ships on the field. The rectangles are placed on field in the following way: the second

Shell特殊变量:Shell $0, $#, $*, $@, $?, $$和命令行参数

心不动则不痛 提交于 2020-02-25 12:04:39
特殊变量列表 变量 含义 $0 当前脚本的文件名 $n 传递给脚本或函数的参数。n 是一个数字,表示第几个参数。例如,第一个参数是$1,第二个参数是$2。 $# 传递给脚本或函数的参数个数。 $* 传递给脚本或函数的所有参数。 $@ 传递给脚本或函数的所有参数。被双引号(" ")包含时,与 $* 稍有不同,下面将会讲到。 $? 上个命令的退出状态,或函数的返回值。 $$ 当前Shell进程ID。对于 Shell 脚本,就是这些脚本所在的进程ID。 命令行参数 运行脚本时传递给脚本的参数称为命令行参数。命令行参数用 $n 表示,例如,$1 表示第一个参数,$2 表示第二个参数,依次类推。 请看下面的脚本: #!/bin/bash echo "File Name: $0" echo "First Parameter : $1" echo "First Parameter : $2" echo "Quoted Values: $@" echo "Quoted Values: $*" echo "Total Number of Parameters : $#" 运行结果: $./test.sh Zara Ali File Name : ./test.sh First Parameter : Zara Second Parameter : Ali Quoted Values: Zara

Shell特殊变量:Shell $0, $#, $*, $@, $?, $$和命令行参数

蹲街弑〆低调 提交于 2020-02-25 12:04:11
特殊变量列表 变量 含义 $0 当前脚本的文件名 $n 传递给脚本或函数的参数。n 是一个数字,表示第几个参数。例如,第一个参数是$1,第二个参数是$2。 $# 传递给脚本或函数的参数个数。 $* 传递给脚本或函数的所有参数。 $@ 传递给脚本或函数的所有参数。被双引号(" ")包含时,与 $* 稍有不同,下面将会讲到。 $? 上个命令的退出状态,或函数的返回值。 $$ 当前Shell进程ID。对于 Shell 脚本,就是这些脚本所在的进程ID。 命令行参数 运行脚本时传递给脚本的参数称为命令行参数。命令行参数用 $n 表示,例如,$1 表示第一个参数,$2 表示第二个参数,依次类推。 请看下面的脚本: #!/bin/bash echo "File Name: $0" echo "First Parameter : $1" echo "First Parameter : $2" echo "Quoted Values: $@" echo "Quoted Values: $*" echo "Total Number of Parameters : $#" 运行结果: $./test.sh Zara Ali File Name : ./test.sh First Parameter : Zara Second Parameter : Ali Quoted Values: Zara

A1016 Phone Bills (25 分)

蹲街弑〆低调 提交于 2020-02-24 16:51:15
A long-distance telephone company charges its customers by the following rules: Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made. When a customer starts connecting a long-distance call, the time will be recorded, and so will be the time when the customer hangs up the phone. Every calendar month, a bill is sent to the customer for each minute called (at a rate determined by the time of day). Your job is to prepare the bills for each month, given a set of phone call records. Input Specification: Each input file contains one test

PAT_A1016#Phone Bills

夙愿已清 提交于 2020-02-24 16:07:19
Source: PAT A1016 Phone Bills (25 分) Description: A long-distance telephone company charges its customers by the following rules: Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made. When a customer starts connecting a long-distance call, the time will be recorded, and so will be the time when the customer hangs up the phone. Every calendar month, a bill is sent to the customer for each minute called (at a rate determined by the time of day). Your job is to prepare the bills for each month, given a set of phone call records. Input

PAT 1016 Phone Bills(模拟)

戏子无情 提交于 2020-02-24 16:05:35
1016. Phone Bills (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A long-distance telephone company charges its customers by the following rules: Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made. When a customer starts connecting a long-distance call, the time will be recorded, and so will be the time when the customer hangs up the phone. Every calendar month, a bill is sent to the customer for each minute called (at a rate determined by the time of day). Your job is to prepare the bills for each month,

PTA (Advanced Level) 1016 Phone Bills

主宰稳场 提交于 2020-02-24 16:03:24
Phone Bills   A long-distance telephone company charges its customers by the following rules:   Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made. When a customer starts connecting a long-distance call, the time will be recorded, and so will be the time when the customer hangs up the phone. Every calendar month, a bill is sent to the customer for each minute called (at a rate determined by the time of day). Your job is to prepare the bills for each month, given a set of phone call records. Input Specification:   Each input file

csv文件数据导出到mongo数据库

最后都变了- 提交于 2020-02-22 13:03:50
from pymongo import MongoClientimport csv# 创建连接MongoDB数据库函数def connection(): # 1:连接本地MongoDB数据库服务 conn=MongoClient("localhost",27017) # 2:连接本地数据库(guazidata)。没有时会自动创建 db=conn.python # 3:创建集合 set1=db.data # 4:授权 db.authenticate(name='zhaochuan', password='123456', source='admin') return set1def insertToMongoDB(set1): # 打开文件 xxx.csv with open('taset.csv','r',encoding='utf-8')as csvfile: # 调用csv中的DictReader函数直接获取数据为字典形式 reader=csv.DictReader(csvfile) # 创建一个counts计数一下 看自己一共添加了了多少条数据 counts=0 for each in reader: # 将数据中需要转换类型的数据转换类型。原本全是字符串(string)。 each['name']=str(each['name']) each['price']=float