不从React JS中的事件进行函数调用

时间:2018-11-11 06:58:06

标签: reactjs javascript-events

在这种情况下,当在getSingleCard函数呈现的元素中发生类似onMouseUp的事件时,我想调用expandDiv函数,但控件没有进入该函数,则什么也没有发生。有人可以帮我解决这个问题。

WikiArea类扩展了组件 {

constructor(props)
{
    super(props);
    this.expandDiv = this.expandDiv.bind(this);
}


render()
{
  if(this.props.result!=null)
  console.log(this.props.result[1]);
  var totalArray = this.props.result;
  var y;
  var self = this;
  if(totalArray!=null)
  {
    return totalArray.map(this.getSingleCard,this);

  }
  else {
    return <div></div>;
  }
}
// onKeyPress ={event => this.onInputChange(event)
//console.log(event.currentTarget.id);this.viewMore.bind(this, attributeId)

getSingleCard(val)
  {
    console.log("syam");
    console.log(self);
    var x=val;
    if(val!=null){
    return (<div className="panel panel-default card-background" id={val["s.no"]}    onMouseUp = {event => {this.expandDiv.bind(this);}}>
      <p>{val["amt.pledged"]}</p>
      <p>{val.blurb}</p>
     </div>);
   }
   else{
     return (<div></div>);
   }
  }
expandDiv(event){
  console.log("Entering into the div");
}

};

0 个答案:

没有答案
相关问题