在ExtJs例子里看到大量“var me = this”,上网找了下,在:http://www.sencha.com/forum/showthread.php?136318-Why-use-quot-var-me-this-quot 找到答案:

Say you have a method in your object A which itself makes an ajax request which has a callback. In this callback you want to use a property "blob" of your original object A. You can not use "this.blob" in this callback because "this" does not refer to your object A anymore (Your scope is in the ajax request). For this reason you save "this" to a variable "me" before you call the function and then refer to "me.blob" to reference the porperty A.blob.

 

就是说当你用到回调函数的时候是无法使用this的,所以要先用me来保存this指针。

引用:http://hi.baidu.com/antzhi/item/8f5c634dd9a221eda5c06608

相关文章:

  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-24
  • 2021-08-01
  • 2021-08-20
猜你喜欢
  • 2022-12-23
  • 2021-06-15
  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案