所以我尝试使用react Js实现一个多页面表单(比如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>
抱歉,如果这个问题看起来很明显,但我只是从react js开始,谢谢
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>
}
<>
};