简介
在本实验中,我们将学习如何在 React 中创建一个不受控的 <select>
元素,使用回调函数将其值传递给父组件。我们将使用 selectedValue
属性来设置 <select>
元素的初始值,并使用 onChange
事件将新值发送给父组件。本实验还将介绍如何使用 Array.prototype.map()
为每个传递的值创建 <option>
元素。
Skills Graph
%%%%{init: {'theme':'neutral'}}%%%%
flowchart RL
react(("React")) -.-> react/FundamentalsGroup(["Fundamentals"])
react/FundamentalsGroup -.-> react/jsx("JSX")
react/FundamentalsGroup -.-> react/event_handling("Handling Events")
react/FundamentalsGroup -.-> react/list_keys("Lists and Keys")
subgraph Lab Skills
react/jsx -.-> lab-38360{{"不受控的选择元素"}}
react/event_handling -.-> lab-38360{{"不受控的选择元素"}}
react/list_keys -.-> lab-38360{{"不受控的选择元素"}}
end