on: function(event, fn) {
var handles = this._handles || (this._handles = {}),
calls = handles[event] || (handles[event] = []);
// 找到对应名字的栈
calls.push(fn);
return this;
}
在这个函数中,return this到底是什么意思,调用这个函数的时候并没有和赋值语句一起使用啊?请问为何还要使用?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
如果你知道jq的链式写法, 就知道为什么要return this了...
方便链式调用
比如obj.foo().bar().baz()
链式调用
指向的是当前对象
jQuery链式调用