Files
react/basic/5/P02.html
T

45 lines
1.3 KiB
HTML
Raw Normal View History

2022-01-10 00:07:02 +08:00
<!--
* @Author: chenxuan
* @Date: 2022-01-08 18:50:31
2022-08-14 13:42:24 +08:00
* @LastEditTime: 2022-08-13 18:51:21
2022-01-10 00:07:02 +08:00
* @LastEditors: chenxuan
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2022-08-14 13:42:24 +08:00
<title>高阶函数</title>
2022-01-10 00:07:02 +08:00
</head>
<body>
<div id="app"></div>
<script src="../package/old/react.development.js"></script>
<script src="../package/old/react-dom.development.js"></script>
<script src="../package/old/babel.min.js"></script>
<script type="text/babel">
class Demo extends React.Component{
2022-03-20 23:55:37 +08:00
state={
name:1
}
2022-01-10 00:07:02 +08:00
saveData=(dataType)=>{
return(e)=>{
this.setState({[dataType]:e.target.value})
}
}
render(){
return (
<div>
2022-03-20 23:55:37 +08:00
<li>{this.name}</li>
2022-01-10 00:07:02 +08:00
<input type="text" onChange={this.saveData('userName')} />
<input type="text" onChange={this.saveData('passworld')} />
</div>
)
}
}
ReactDOM.render(
<Demo/>,document.getElementById('app')
)
</script>
</body>
</html>