Twitter bootstrap 具有处理程序函数但没有返回类型的引导模式绑定事件
我正在检查boostrap模式源代码,想知道Twitter bootstrap 具有处理程序函数但没有返回类型的引导模式绑定事件,twitter-bootstrap,bootstrap-modal,Twitter Bootstrap,Bootstrap Modal,我正在检查boostrap模式源代码,想知道$this.is(':visible')&&$this.trigger('focus')是否返回对象,然后返回以下代码 $target.one('hidden.bs.modal', function () { $this.is(':visible') && $this.trigger('focus') }) 将是 $target.one('hidden.bs.modal', function () { [
$this.is(':visible')&&$this.trigger('focus')
是否返回对象,然后返回以下代码
$target.one('hidden.bs.modal', function () {
$this.is(':visible') && $this.trigger('focus')
})
将是
$target.one('hidden.bs.modal', function () {
[Object object]
})
这个代码是什么意思 这实际上并不等同。对
的函数调用是
并且触发了触发器
(此时忽略快捷方式)。变量既不存储也不返回。回到快捷键:focus
仅在visible
为true时触发。所以实际上没有从eone
返回任何值,它只是一个回调。。。。这有意义吗?因此它相当于if($this.is(':visible'){$this.trigger('focus')}
?是的,但这不是一种很好的编写方法。正确的术语是短路(不是短路,我的错)。至于编辑后,不同的语言可以解释对象为布尔值:在C++中,如果不是<代码> 0 < /COD>,所有的东西都会被评估为<代码>真< /代码>。对于VB6;false=0,true=-1,其他一切都不确定。也许这篇关于javascript的文章可以帮助您: