这个if语句返回空做什么在Bootstrap模式的源代码
What does this if statement return empty do in Bootstrap modal source code?
我正在检查引导模态源代码,并发现这样一行。这个if (!this.isShown || e.isDefaultPrevented()) return
做什么?在我看来,if()中的代码是否被评估为false
或true
,该代码片段中的其余代码仍将执行。那么设置这样的行和return
为空有什么意义呢?
Modal.prototype.hide = function (e) {
if (e) e.preventDefault()
e = $.Event('hide.bs.modal')
this.$element.trigger(e)
if (!this.isShown || e.isDefaultPrevented()) return
this.isShown = false
this.escape()
this.resize()
$(document).off('focusin.bs.modal')
this.$element
.removeClass('in')
.attr('aria-hidden', true)
.off('click.dismiss.bs.modal')
.off('mouseup.dismiss.bs.modal')
this.$dialog.off('mousedown.dismiss.bs.modal')
$.support.transition && this.$element.hasClass('fade') ?
this.$element
.one('bsTransitionEnd', $.proxy(this.hideModal, this))
.emulateTransitionEnd(Modal.TRANSITION_DURATION) :
this.hideModal()
}
if (!this.isShown || e.isDefaultPrevented()) return;
对于
来说,这更像是一行代码if (!this.isShown || e.isDefaultPrevented()){
return;
}
这仅仅意味着如果模式已经显示(this.isShown
将为真),或者如果事件的默认动作被阻止,简单地从这个方法返回without executing any further statements
-在这种情况下,这意味着不要隐藏模式。
return
指令是立即的,并中断函数的执行。
相关文章:
- 如何动态更改React Bootstrap模式的内容
- 在Bootstrap模式窗口中打开远程内容
- bootstrap模式在windowsvista上的IE8上运行极其缓慢
- Jquery UI don'使用bootstrap 3模式时效果不佳
- 在ajax回调(safari)中调用bootstrap模式显示
- 一旦Bootstrap模式选项已经存在,请更改该选项
- 当内部的任何模式关闭时,Bootstrap模式关闭
- bootstrap日期选择器轨道无法通过带有bootstrap模式的simple_form工作
- Bootstrap 3模式从水平到内联的变化-调整大小很尴尬
- Twtitter Bootstrap模式显示事件多次触发
- 确定哪个按钮打开了Bootstrap 3模式
- 如何使用 javascript 隐藏 Bootstrap 模式
- Bootstrap模式加载远程内容,生成2个请求
- c#asp.net如何使用bootstrap模式将视频源文件名添加到不同的媒体类型中
- bootstrap模式中的Twitter共享按钮在firefox上不起作用
- Bootstrap 3模式并不总是激活ajax代码
- PHP和Bootstrap模式变量
- Bootstrap 3模式-从底部滑入并粘牢
- 如何清理(销毁)Twitter Bootstrap 3.2模式表单内容
- 如何在AngularJS Bootstrap模式中从AJAX调用加载JSON数据