【发布时间】:2018-06-16 08:17:28
【问题描述】:
我有要用于填充单选按钮的数据,但有些数据长度比其他数据长,并且如果长度只有一个,我不想要空按钮。我可能想多了,但我很烂。
我已经尝试通过 props.size 数据进行映射,所以我可以这样填充它,但我收到一个错误,说 map 不是函数。
这是我的 Button 文件:
import React from "react";
const EyewearPurchaseBtn = (props) => (
<div>
<form className="eyewear-purchase-form">
<h3>Select Size</h3>
<div>
<input className="radio-btn" type="radio" checked="checked"/>
<label className="eyewear-purchase-label">{props.sizes}</label><br/>
<input className="radio-btn" type="radio" />
<label className="eyewear-purchase-label">Two</label><br/>
<input className="radio-btn" type="radio" />
<label className="eyewear-purchase-label">Three</label><br/>
<input className="radio-btn" type="radio" />
<label className="eyewear-purchase-label">Four</label>
<button onClick={props.handlePurchaseEvent} className="buy-now">Buy Now</button>
</div>
</form>
</div>
);
export default EyewearPurchaseBtn;
【问题讨论】:
标签: javascript html reactjs