繁体   English   中英

引导程序和jQuery模式失败

[英]bootstrap and jquery modal failing

我正在使用Bootstrap和jQuery,并且使用文本属性触发了打开操作,使模态内容正常运行。

但是,我试图从另一个脚本关闭打开的模态窗口,但出现错误,提示modal is not defined

modals.js:94 Uncaught TypeError: $(...).modal is not a function(anonymous function) @ modals.js:94dispatch @ jquery.min.js:3r.handle @ jquery.min.js:3
modals.js:86 Object {__ob__: Observer, __v-for__1: Fragment}

代码如下:

$('#mymodal').modal('hide');

js文件的加载顺序为:

<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.js"></script>
<script src="/modals.js" type="text/javascript"></script>

如果模式窗口通过data-toggle="modal"调用正确运行,如何不定义data-toggle="modal"

可能其他脚本重写了bootsrap模态函数$.fn.modal

如果为真,则需要解决冲突:

var bootstrapModal = $.fn.modal.noConflict();
$.fn.bootstrapModal = bootstrapModal;
$('#mymodal').bootstrapModal('hide');

敲了敲我的脑袋后,这是由于另一个我不知道的通过凉亭安装导入的jQuery版本。 一旦我知道在哪里寻找,就可以轻松删除此重复的jQuery,并且该站点可以按预期工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM