import { useState } from "react" export default function App() { const [count, setCount] = useState(0) return ( <div> <h2>计数: {count}</h2> <button onClick={() => setCount(c => c + 1)}>+1</button> <button onClick={() => setCount(c => c - 1)}>-1</button> </div> ) }