1 回答

TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超9個(gè)贊
經(jīng)過長(zhǎng)時(shí)間的研究,問題出id在inputs. 它們需要是獨(dú)一無二的,所以我像那樣更新了我的代碼=>
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>
)
添加回答
舉報(bào)