我正在开发骨干应用程序。我正在使用调用函数的mousedown
主干添加事件。我正在设置的select
内部函数调用另一个函数。在功能中,我想使用. 但是,未定义,因为 this 不引用我当前的模块。我怎样才能保留这个关键字,以便我可以在选择功能中使用它?select
timeout
selection
selection
currently clicked element
console.log(this.el)
this.el
这是我的代码
events: {
'mousedown': 'select',
'mouseup': 'deselect'
},
select: function () {
this.timeoutId = setTimeout(this.selection, 1000);
},
deselect: function () {
clearTimeout(this.timeoutId);
},
selection: function () {
console.log(this.el);
}