Last active
August 29, 2015 13:58
-
-
Save joecliff/9927180 to your computer and use it in GitHub Desktop.
使用q.js调用不支持promise的方法时的作用域问题
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//最好总是使用带this绑定的q方法(相对保险) | |
Q.ninvoke(object, methodName, ...args); //直接执行 | |
Q.nbind(nodeMethod, thisArg, ...args); //返回绑定参数后的方法 | |
//不带直接绑定this作用域的,如果方法内用到了this,可能需要手动绑定 | |
Q.nfcall(obj.method.bind(obj), ...args) | |
Q.nfapply(obj.method.bind(obj), args) | |
//其他类似 ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment