使用"这个"使用ReactJs从内部回调函数内部指针

时间:2016-04-14 16:26:28

标签: javascript reactjs

使用 ReactJs ,我想在地图功能的回调中插入$('.ws-table-list').on('click', 'th', function() { console.log('click'); // This only runs once in the console $('span', this).toggleClass('glyphicon-menu-up glyphicon-menu-down'); }); ,但我找不到方法。

this

1 个答案:

答案 0 :(得分:0)

使用.bind修复

render:function()
var DateTimeField = require('react-bootstrap-datetimepicker');
console.log(this);    
console.log(123);


var cards = this.state.nameWithQualifier.map(function (card,this) {

return (        
<div > 
  <div className={"panel panel-primary" + this.state.workState}>
    <div className={ "panel-body " + card.insertTime } >
     <label className="col-md-9 checkbox-inline">
        <input type="checkbox" className={card.insertTime} ></input>
        {card.insertText}
      </label>
      <div className="col-md-3"> DeadLine :  {card.insertTime}</div>           
    </div>
  </div>
</div>
);}.bind(this));