无法在 window.resize() 中访问对象的上下文

Can't access an object's context in window.resize()

本文关键字:访问 对象 上下文 window resize      更新时间:2023-09-26

我可以在其他方法中以这种方式处理上下文,但我不确定 .resize() 有什么不同,或者为什么我无法在上下文中传递。

 D4.prototype.resize = function() {
    var that = this;
    that.containerBound = that.getBound(that.containerId);
    // that is referring to the DomWindow and not D4
  };
  $(window).resize(D4.prototype.resize);

您是否尝试过这样做:

$(window).resize(function() {
    D4.prototype.resize('prototype:');
    myD4.resize('instance:')
});