有几种方法可以做到这一点。
您可以设置
contextajax选项的设置:
jQuery.ajax
context
设置
$.ajax({ context: this[Function.prototype.bind
](https://developer.mozilla.org/en-
US/docs/Web/Javascript/Reference/Global_Objects/Function/bind)
.done(function (res) { }.bind(this));但是,它没有像…那样得到广泛的支持。
jQuery.proxy
为此创建的。
.done($.proxy(function (res) { }, this);将此分配给另一个值
var self = this;$.ajax({.done(function (res) { self.loadResults(res);这通常是在Javascript中完成的,以便
this在较低范围内进行访问。
具有词法绑定的箭头功能
$.ajax({.then(res => this.loadResults(res));


