react PropTypes校验传递的值操作示例
本文实例讲述了reactPropTypes校验传递的值操作。分享给大家供大家参考,具体如下:
校验传递的值:
importReact,{Component,Fragment}from'react';
importListfrom'./List.js';
classTestextendsComponent{
constructor(props){
super(props);
this.state={
inputValue:'aaa',
list:['睡觉','打游戏'],
}
//this.add=this.add.bind(this);
}
addList(){
this.setState({
list:[...this.state.list,this.state.inputValue],
inputValue:''
})
}
change(e){
this.setState({
inputValue:e.target.value
})
}
delete(i){
//console.log(i);
constlist=this.state.list;
list.splice(i,1);
this.setState({
list:list
})
}
render(){
return(
添加
{
this.state.list.map((v,i)=>{
return(
);
})
}
);
}
}
exportdefaultTest;
importReact,{Component}from'react';
importPropTypesfrom'prop-types';
classListextendsComponent{
constructor(props){
super(props);
this.delete=this.delete.bind(this);
}
render(){
return(
希望本文所述对大家react程序设计有所帮助。
热门推荐
10 病人祝福语老师寄语简短
11 新娘生孩子祝福语简短
12 婆婆66岁祝福语简短
13 今天孩子高考祝福语简短
14 送彩票生日祝福语简短
15 分别祝福语简短情话英文
16 画室揭牌仪式祝福语简短
17 女友妈妈生日祝福语简短
18 离别赠言离职祝福语简短