在选项中使用哪个属性,以便在单击它时在onChange事件中获取值?
function App() {
const [category, setCategory] = useState("");
return (
<div className="App">
<select
value={category}
onChange={({ target: { value } }) => {
setCategory(value);
}}
>
<option ?={"1"}>{"Black"}</option>
<option ?={"2"}>{"White"}</option>
<option ?={"3"}>{"Pink"}</option>
<option ?={"4"}>{"Red"}</option>
<option ?={"5"}>{"Gray"}</option>
</select>
</div>
);
}
答案 0 :(得分:1)
您需要用于library(gganimate)
library(dplyr)
library(forcats)
df1 <- data.frame("Time" = c("Summer", "Winter"),
"Blood.Pressure" = c(21,15),
"Name" = c("John","John"))
df1 %>%
ggplot(aes(x = Name, y = Blood.Pressure)) +
geom_point(size = 5) +
coord_flip() +
theme(legend.position = 'none') +
transition_states(
fct_rev(Time),
transition_length = 1,
state_length = 2) +
shadow_mark(color = 'black', size = 5, alpha = .25) +
labs(title = "John's Blood Pressure In",
subtitle = "{closest_state}",
x = " ",
y = "Blood Pressure")
元素的属性是普通的option
属性。
value
React添加到<option value={"1"}>{"Black"}</option>
元素的唯一特殊添加是使用select
设置所选选项的功能,而无需手动将value
属性分配给{{1 }}元素。