1 回答
TA贡献1831条经验 获得超9个赞
经过长时间的研究,问题出id在inputs. 它们需要是独一无二的,所以我像那样更新了我的代码=>
return(
<fieldset className="rating" >
<input type="button" onClick={onClick} id={"star5"+props.post.id} name="rating" value="5" /><label className = "full" htmlFor={"star5"+props.post.id}></label>
<input type="button" onClick={onClick} id={"star4half"+props.post.id} name="rating" value="4.5" /><label className="half" htmlFor={"star4half"+props.post.id} ></label>
<input type="button" onClick={onClick} id={"star4"+props.post.id} name="rating" value="4" /><label className = "full" htmlFor={"star4"+props.post.id} ></label>
<input type="button" onClick={onClick} id={"star3half"+props.post.id} name="rating" value="3.5" /><label className="half" htmlFor={"star3half"+props.post.id} ></label>
<input type="button" onClick={onClick} id={"star3"+props.post.id} name="rating" value="3" /><label className = "full" htmlFor={"star3"+props.post.id} ></label>
<input type="button" onClick={onClick} id={"star2half"+props.post.id} name="rating" value="2.5" /><label className="half" htmlFor={"star2half"+props.post.id} ></label>
<input type="button" onClick={onClick} id={"star2"+props.post.id} name="rating" value="2" /><label className = "full" htmlFor={"star2"+props.post.id} ></label>
<input type="button" onClick={onClick} id={"star1half"+props.post.id} name="rating" value="1.5" /><label className="half" htmlFor={"star1half"+props.post.id} ></label>
<input type="button" onClick={onClick} id={"star1"+props.post.id} name="rating" value="1" /><label className = "full" htmlFor={"star1"+props.post.id} ></label>
<input type="button" onClick={onClick} id={"starhalf"+props.post.id} name="rating" value="0.5" /><label className="half" htmlFor={"starhalf"+props.post.id}></label>
</fieldset>
)
添加回答
举报