获取错误未捕获的ReferenceError:未定义BootstrapDialog

时间:2022-11-06 15:08:30

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

我正在尝试使用Bootstrap的模态来发送推文。我将modal.js和bootstrap.min.js下载到我的JavaScript文件中,但是我收到错误:

Uncaught ReferenceError: BootstrapDialog is not defined.

未捕获的ReferenceError:未定义BootstrapDialog。

Anyone know what I'm doing wrong?

谁知道我做错了什么?

HTML:

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

JavaScript:

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

5 个解决方案

#1


3  

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)

#2


1  

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

您需要在JavaScript运行之前的某处获取bootstrap-dialog.min.js文件。

#3


1  

<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>

#4


1  

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.

注意:-THIS解决方案为我工作可能或可能不适合你。

#5


0  

Just add both to the head section

只需将两者都添加到头部

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

#1


3  

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)

#2


1  

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

您需要在JavaScript运行之前的某处获取bootstrap-dialog.min.js文件。

#3


1  

<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>

#4


1  

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.

注意:-THIS解决方案为我工作可能或可能不适合你。

#5


0  

Just add both to the head section

只需将两者都添加到头部

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