我如何设置,一旦paypal的单选按钮被点击,文本字段类型的数字将被显示,然后,如果它没有被点击,它将保持隐藏?
此外,一旦点击了COD,它将显示一条类似"cod is payment for the payment option“的消息
const page = () => {
const [payment, setPayment] = useState();
return (
<div>
<Container fixed>
<form onSubmit={handleSubmit}>
<Typography align="left" variant="subtitle1" color="secondary">
Choose Payment Option
</Typography>
<input
type="radio"
value="cod"
name="paymentMethod"
onChange={(e) => setPayment(e.target.value)}
/>
COD(Cash-on-Delivery)<br></br>
<input
type="radio"
value="paypal"
name="paymentMethod"
onChange={(e) => setPayment(e.target.value)}
/>{" "}
Gcash
<TextField
id="gcash-num"
label="paypal"
type="number"
fullWidth
/>
<Button type="submit">Place an Order</Button>
发布于 2021-05-04 11:12:09
将此代码插入到jsx中:
{
payment === "paypal" &&
<TextField
id="gcash-num"
label="paypal"
type="number"
fullWidth
/>
}
{
payment === "cod" &&
<p>cod is chosen for the payment option</p>
}
https://stackoverflow.com/questions/67383361
复制相似问题