因此,当输入是文本字段时,我尝试使用react实现多个页面表单(如typeform) --所有这些都是很好的示例
<input id="input-2" type="text" placeholder="H/F" required />
<label for="input-2">
<span class="label-text">Sexe</span>
<span class="nav-dot"></span>
</label>但是当输入是单选按钮时,它就不再显示了。
<div id="input-3" >
<input type="radio" value="male" name= "sexe" required /> Male
<input type="radio" value="female" name= "sexe" required /> Female
<label for="input-3">
<span class="label-text">Sexe?</span>
<span class="nav-dot"></span>
</label>
</div>对不起,如果问题似乎很明显,但我只是从反应开始,谢谢
发布于 2021-01-02 14:41:17
import React, { useState } from 'react';
const [isFormDisplay, setFormDisplay] = useState(false);
// DO LOGIC WHEN YOU WANT TO DISPLAY THE FORM OR NOT
return {
<>
{!isFormDisplay &&
<input id="input-2" type="text" placeholder="H/F" required />
<label for="input-2">
<span class="label-text">Sexe</span>
<span class="nav-dot"></span>
</label>
}
{isFormDisplay &&
<div id="input-3">
<input type="radio" value="male" name= "sexe" required /> Male
<input type="radio" value="female" name= "sexe" required /> Female
<label for="input-3">
<span class="label-text">Sexe?</span>
<span class="nav-dot"></span>
</label>
</div>
}
<>
};https://stackoverflow.com/questions/65540235
复制相似问题