Javascript 引导datetimepicker中的未捕获引用错误
我正在做一个关于Javascript 引导datetimepicker中的未捕获引用错误,javascript,jquery,asp.net-mvc,twitter-bootstrap,datetimepicker,Javascript,Jquery,Asp.net Mvc,Twitter Bootstrap,Datetimepicker,我正在做一个关于MVC的项目,其中我在表单字段中添加了日期时间选择器,我已经下载了bootstrap-datetimepicker 我已经将JS和CSS文件提取到我的项目中,但仍然显示出一些错误 错误是: VM199:2 Uncaught ReferenceError: moment is not defined at HTMLDocument.eval (eval at globalEval (jquery-2.1.4.js:328), <anonymous>:2:42)
MVC
的项目,其中我在表单字段中添加了日期时间选择器,我已经下载了bootstrap-datetimepicker
我已经将JS
和CSS
文件提取到我的项目中,但仍然显示出一些错误
错误是:
VM199:2 Uncaught ReferenceError: moment is not defined
at HTMLDocument.eval (eval at globalEval (jquery-2.1.4.js:328), <anonymous>:2:42)
at fire (jquery-2.1.4.js:3099)
at Object.add [as done] (jquery-2.1.4.js:3145)
at jQuery.fn.init.jQuery.fn.ready (jquery-2.1.4.js:3378)
at jQuery.fn.init (jquery-2.1.4.js:2821)
at jQuery (jquery-2.1.4.js:76)
at eval (eval at globalEval (jquery-2.1.4.js:328), <anonymous>:1:1)
at eval (<anonymous>)
at Function.globalEval (jquery-2.1.4.js:328)
at jQuery.fn.init.domManip (jquery-2.1.4.js:5435)
VM199:2未捕获引用错误:未定义力矩
在HTMLDocument.eval上(在globalEval上的eval(jquery-2.1.4.js:328),:2:42)
着火时(jquery-2.1.4.js:3099)
在Object.add[完成时](jquery-2.1.4.js:3145)
在jQuery.fn.init.jQuery.fn.ready上(jQuery-2.1.4.js:3378)
在jQuery.fn.init(jQuery-2.1.4.js:2821)
在jQuery上(jQuery-2.1.4.js:76)
在评估时(在globalEval时评估)(jquery-2.1.4.js:328),:1:1)
评估时()
在Function.globalEval(jquery-2.1.4.js:328)
在jQuery.fn.init.domManip(jQuery-2.1.4.js:5435)
要使引导日期时间选择器正常工作,需要在标记中添加以下一组文件
> jQuery
> Moment.js
> Bootstrap.js (transition and collapse features are required if you're not using the full Bootstrap)
> Bootstrap Datepicker script
> Bootstrap CSS
> Bootstrap Datepicker CSS
初始化日期时间选择器
$("#fromDate").datetimepicker({
sideBySide: true,
debug:false,
useCurrent: false,
format: 'YYYY-MM-DD HH:mm:ss'
})
<div class="input-group date" id="fromDate">
<input type="text" class="form-control" name="fromDate"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
$(“#fromDate”).datetimepicker({
是的,
调试:错误,
useCurrent:false,
格式:“YYYY-MM-DD HH:MM:ss”
})
DateTimepicker有很多可定制的功能。要了解更多信息,请参阅我已解决了我的错误,这是由于代码中其他地方定义了重复的函数。似乎您的页面中没有包含
矩.js
?您的代码使用,但该页面中未包含此信息。请仅使用moment.js的cdn查看它是否正常工作,请确保在使用它之前加载了moment.js。相关消息不是Uncaught ReferenceError
,而是未定义moment
。检查是否包含momentjs库。