我认为这很简单,但它不起作用(http://jsfiddle.net/QtjaG/上的实时示例):
$.resx = function() {
var result = this;
return $.get("/", function() {
result = "yo";
});
};
var labels;
$.resx.call(labels).then(function() {
console.log(labels);
});
由于$.resx.call(labels)
应该将this
上下文设置$.resx()
为labels
,不应该console.log(labels)
记录yo
吗?