Bootstrap 日期时间选择器 installation/configuration

Bootstrap datetimepicker installation/configuration

我在 eonasdan bootstrap datetimepicker 的基本配置方面遇到了一些问题。

我用相同插件的旧版本创建了一个 fiddle using the code from their basic setup instructions to show my configuration. I see another Whosebug question on this topic that has another fiddle。这两个 fiddle 看起来很相似,但我的不行。

<div class="container">
    <div class="row">
        <div class='col-sm-6'>
            <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>
        <script type="text/javascript">
            $(function () {
                $('#datetimepicker1').datetimepicker();
            });
        </script>
    </div>
</div>

为什么我的 fiddle 中的日期时间选择器不起作用?

如果您 运行 您的 fiddle 在检查控制台时您将看到以下错误:

uncaught exception: bootstrap-datetimepicker requires Moment.js to be loaded first

所以这只是脚本加载顺序的问题。 This 与 fiddle 完全相同,除了 bootstrap-datetimepicker.min.js 是最后加载的,并且它有效。

只需注意按正确顺序加载资源,或使用依赖管理工具为您整理。