Closed chyroc closed 2 years ago
import {Button, Input, Text, Textarea} from "@geist-ui/core"; import {useState} from "react"; export default function IndexPage() { const [title, setTitle] = useState(""); const [content, setContent] = useState(""); return ( <div style={{margin: 30}}> <Text> <Text span style={{marginRight: 10}}>标题:</Text> <Input placeholder="标题" onClick={e => setTitle(e.target.value)}/> </Text> <Text> <Text span style={{marginRight: 10}}>内容:</Text> <Textarea width="200" onClick={e => setContent(e.target.value)}/> </Text> <Button auto onClick={() => { console.log({title, content}) }}>提交</Button> </div> ) }
You need change onClick to onChange for capture the value changes:
onClick
onChange
<Textarea width="200" onChange={e => setContent(e.target.value)}/>
codesandbox example