如何将 `this` 传递给 typeahead.js 事件

How to pass `this` to typeahead.js event

我正在使用 typeahead.js 库在我的应用程序中进行搜索。我整理了以下搜索,但不幸的是,最后我无法访问 this。这是当前代码:

$('#search-field').typeahead({hint:false, minLength: 2}, {
  configSetings: settings,
}).bind('typeahead:select', function(obj, datum) {
  this.history.pushState(null, `/term/${datum.permalink}`);
});

我试图调用 .bind(this)typeahead:select 事件,但是当我这样做时,我以错误告终:

Uncaught TypeError: m.push is not a function

我不知道如何解决这个问题。有任何想法吗?我正在使用 ReactJS、Webpack 和 Typeahead.js。

这个怎么样:

$('#search-field').typeahead({hint:false, minLength: 2}, {
  configSetings: settings,
}).bind('typeahead:select', (function(obj, datum) {
  this.history.pushState(null, '', `/term/${datum.permalink}`);
}).bind(this));