jQuery 获取错误 Uncaught ReferenceError: BootstrapDialog 未定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28436634/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 16:28:32  来源:igfitidea点击:

getting error Uncaught ReferenceError: BootstrapDialog is not defined

jquerytwitter-bootstrapmodal-dialog

提问by LauraNMS

I'm trying to use Bootstrap's modal to send tweets. I downloaded modal.jsand bootstrap.min.jsinto my JavaScript file, but I'm getting the error:

我正在尝试使用 Bootstrap 的模式来发送推文。我将modal.jsbootstrap.min.js下载到我的 JavaScript 文件中,但出现错误:

Uncaught ReferenceError: BootstrapDialog is not defined.

未捕获的 ReferenceError: BootstrapDialog 未定义。

Anyone know what I'm doing wrong?

有谁知道我做错了什么?

HTML:

HTML:

<script src="js/bootstrap.min.js"></script>
<script src="js/modal.js"></script>
<script src="js/scripts.js"></script> <!-- my jquery file -->

JavaScript:

JavaScript:

setTimeout(function() {
    BootstrapDialog.alert('I want banana!');
}, 1000);

回答by Jeremy Thille

You're calling a plugin BootstrapDialog (https://github.com/nakupanda/bootstrap3-dialog) but not including it in your JS files. You're not using only the Bootstrap default modal (http://getbootstrap.com/javascript/#modals)

您正在调用插件 BootstrapDialog ( https://github.com/nakupanda/bootstrap3-dialog),但未将其包含在您的 JS 文件中。您不仅使用 Bootstrap 默认模式 ( http://getbootstrap.com/javascript/#modals)

回答by amphetamachine

You need to source the bootstrap-dialog.min.jsfile somewhere before your JavaScript runs.

bootstrap-dialog.min.js在 JavaScript 运行之前,您需要在某处找到该文件的来源。

回答by Waqar Detho

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/css/bootstrap-dialog.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/js/bootstrap-dialog.min.js"></script>

回答by Sanket

setTimeout(function(){
    BootstrapDialog.alert('I want banana!');
}, 1000);

also you have to include this script in your main html file.

您还必须将此脚本包含在主 html 文件中。

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/js/bootstrap-dialog.min.js"></script>  
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/css/bootstrap-dialog.min.css"> 

Also do keep a track on the order in which you are including these scripts.

还要跟踪包含这些脚本的顺序。

NOTE:-THIS SOLUTION WORKED FOR ME IT MAY OR MAY NOT WORK FOR YOU.

注意:-此解决方案对我有用,可能对您也可能不起作用。

回答by Suhail Mumtaz Awan

Just add both to the head section

只需将两者都添加到 head 部分

https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/css/bootstrap-dialog.min.css

https://cdnjs.cloudflare.com/ajax/libs/bootstrap3-dialog/1.34.7/js/bootstrap-dialog.min.js