- 博客(3)
- 收藏
- 关注
原创 React中文文档 9. 表单
1.受控组件class NameForm extends React.Component { constructor(props) { super(props); // 初始化 this.state = {value: ''}; // 如果不初始化state或不进行方法绑定,则不需要为React组件实现构造函数 } handleChange = (event) => { this.setState({value: event.target..
2022-05-10 00:56:09
319
原创 React中文文档 8. 列表 & Key
1.遍历const numbers = [1, 2, 3, 4, 5];const listItems = numbers.map((number) => <li>{number}</li>);ReactDOM.createRoot(document.getElementById('root')).render(<ul>{listItems}</ul>);2.基础列表组件function NumberList(props)
2022-05-10 00:13:56
439
原创 React中文文档 7. 条件渲染
1.条件渲染function UserGreeting(props) { return <h1>Welcome back!</h1>;}function GuestGreeting(props) { return <h1>Please sign up.</h1>;}function Greeting(props) { const isLoggedIn = props.isLoggedIn; if (isLoggedIn) { .
2022-05-09 22:43:51
131
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅