var RechargeBtnEle = React.createClass({ getInitialState: function() { return {id:0}; }, handleClick(item,item1){ console.log(item,item1) }, render(){ let btnArr = this.props.data var newArr = [] for(let i=0;i<btnArr.length;i++){ var item = btnArr[i] let styleObj = this.state.id==item.id?["recharge","btn","btn-default","btn-sm","selected"].join(‘ ‘):["recharge","btn","btn-default","btn-sm"].join(" ") newArr.push( <div className={styleObj} onClick={this.handleClick.bind(this.item,item)} >{`${item.diamond}钻石`}</div> ) } return( <div className="charge-btn"> {newArr} </div> ) } })
时间: 2024-10-28 20:25:19