首页 > 解决方案 > 没有从反应js中的事件调用函数

问题描述

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

class  WikiArea extends Component
{

    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");
    }
};

标签: javascriptreactjsdom-events

解决方案


推荐阅读