twitter-bootstrap Twitter Bootstrap 日期选择器错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15606022/
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
Twitter Bootstrap Datepicker error
提问by John
I tried everything but can't get the datepicker to show up.
我尝试了所有方法,但无法显示日期选择器。
Bootstrap version v2.3.1.
引导程序版本 v2.3.1。
Latest version of http://www.eyecon.ro/bootstrap-datepicker/
最新版http://www.eyecon.ro/bootstrap-datepicker/
HTML:
HTML:
<div class="input-append date" id="dpMonths" data-date="102/2012" data-date-format="yyyy-mm" data-date-viewmode="years" data-date-minviewmode="months">
<input class="" size="16" type="text" value="2013-03" readonly>
<span class="add-on"><i class="icon-calendar"></i></span>
<script src="js/bootstrap-datepicker.js"></script>
<script type="text/javascript">
$(function() {
$('#dpMonths').datepicker();
});
</script>
Javascript error:
Javascript 错误:
Uncaught TypeError: Cannot read property 'fn' of undefined
未捕获的类型错误:无法读取未定义的属性“fn”
Uncaught ReferenceError: $ is not defined
未捕获的 ReferenceError: $ 未定义
回答by Eli Stone
You need to have jquery included to get the bootstrap date picker working
您需要包含 jquery 才能使引导程序日期选择器工作
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="js/bootstrap-datepicker.js"></script>
Also add the CSS file for bootstrap datepicker in the head of your page.
还要在页面的头部添加用于引导日期选择器的 CSS 文件。

