[英]Error With Bootstrap 3 Date/Time Picker
I am using the date/time picker from Eonasden that you can find here. 我正在使用Eonasden的日期/时间选择器,你可以在这里找到。 Date Time Picker
日期时间选择器
I am using HTML from the example: 我正在使用示例中的HTML:
<div class="container">
<div class="col-md-10">
<div class='well'>
<div class="form-group">
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" />
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>
</div>
It displays the icon fine, but not the calendar drop down. 它显示图标正常,但不显示日历下拉菜单。 My head script is:
我的头像是:
<link href="view/dist/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="view/dist/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<link href="http://cdnjs.cloudflare.com/ajax/libs/jasny-bootstrap/3.0.1-p7/css/bootstrap.min.css" rel="stylesheet" >
<script src="http://code.jquery.com/jquery.js"></script>
<script src="view/dist/js/bootstrap.min.js"></script>
<script src="view/dist/js/bootstrap-datetimepicker.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jasny-bootstrap/3.0.1-p7/js/bootstrap.min.js"></script>
$(function() {
$( document ).ajaxStop( function() {
$('#datetimepicker1').datetimepicker();
});
});
I receive a console error of "Uncaught ReferenceError: moment is not defined" Does anyone have an idea on how to fix this? 我收到一个控制台错误“未捕获的ReferenceError:时刻未定义”有没有人知道如何解决这个问题? It seems to work fine on his sample page.
它似乎在他的示例页面上正常工作。
According to the examples, you need to include this to.. 根据示例,您需要将此包含在..
http://momentjs.com/ http://momentjs.com/
It has to be after bootstrap.js
, but before the datetimepickerjs
like this.. 它必须在
bootstrap.js
之后,但是在datetimepickerjs
之前就是这样的..
<script type="text/javascript" src="scripts/bootstrap.min.js"></script>
<script type="text/javascript" src="scripts/moment-2.4.0.js"></script>
<script type="text/javascript" src="scripts/bootstrap-datetimepicker.js"></script>
It shows it on the GitHub readme.. 它在GitHub自述文件中显示..
"Datetimepicker requires moment.js."
“Datetimepicker需要moment.js。”
Simple solution 简单解决方案
Once even I got the same error. 一旦我得到同样的错误。 I was able to fix that by including the content delivery network or content distribution network (CDN) link of the script file.
我能够通过包含脚本文件的内容传送网络或内容分发网络(CDN)链接来解决这个问题。
Try the code below: 请尝试以下代码:
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.12.0/moment.js"></script>
Include the above code before adding-in the bootstrap-datetimepicker.js
在添加bootstrap-datetimepicker.js之前包含上面的代码
I found wrapping your code in 我发现包装你的代码
$( document ).ajaxStop( function() {});
fixed it for me 为我修好了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.