0
点赞
收藏
分享

微信扫一扫

前端学习笔记202309学习笔记第九十一天-闭包22

工程与房产肖律师 2023-11-21 阅读 42

const {useState}=React

function App(){
    const [title,setTitle]=useState("this is a title")
    const [content,setContent]=useState("this is a content")
    return (
        <div>
            <h1>{title}</h1>
            <button onClick={()=>setTitle("这是标题")}>set title</button>
            <p>{content}</p>
            <button onClick={()=>setContent("这是内容")}>set content</button>
        </div>
    )
}

const root=ReactDOM.createRoot(document.querySelector('#app'));
root.render(<App/>)

运行结果

 

前端学习笔记202309学习笔记第九十一天-闭包22_App



举报

相关推荐

0 条评论