1

我希望我的 datetimepicker 在https://tempusdominus.github.io/bootstrap-4/Usage/#no-icon-input-field-only(无图标(仅限输入字段))中显示为第 5 个 datetimepicker。

但是,当仅使用 CDNJS 时,输出是示例中显示的变形版本。为了解决这个问题,我通过归属于本地路径来包含在下面的链接中找到的源代码。这使得 datetimepicker 根本不显示。

源代码:https ://github.com/tempusdominus/bootstrap-4

既不包括仅 CDNJS,也不包括源代码(本地路径),两者都有效。

我希望将来能够更改颜色,因此使用源代码进行更改对我更有利...

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.0.1/js/tempusdominus-bootstrap-4.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.0.1/css/tempusdominus-bootstrap-4.min.css" />

<link rel="stylesheet" type="text/css" href="lib/datetimepicker/tempusdominus-bootstrap-4.min.css" >
<script type="text/javascript" src="lib/datetimepicker/tempusdominus-bootstrap-4.min.js"></script>
 <div class="col-lg-12">
        <input type="text" class="form-control datetimepicker-input" id="datetimepicker5" data-toggle="datetimepicker" data-target="#datetimepicker5" placeholder="Data e Hora">
 </div>
<script>
        $(function () {
        $('#datetimepicker5').datetimepicker();
    });
</script>
4

1 回答 1

2

(1)为了让下拉菜单按预期工作,我必须添加

  • 字体真棒.css
  • 时刻.js
  • tempusdominus-bootstrap-4.min.js
  • tempusdominus-bootstrap-4.css

(2) 为打开的日历设置样式,我添加了以下内容:.bootstrap-datetimepicker-widget table td{ color:red;}您可以自己进行相关更改

完整的工作片段如下;

.bootstrap-datetimepicker-widget table td {
  color: red;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/github.min.css" />

<script src="https://momentjs.com/downloads/moment.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.0.0-alpha14/js/tempusdominus-bootstrap-4.min.js"></script>
<link rel="stylesheet" href="https://tempusdominus.github.io/bootstrap-4/theme/css/tempusdominus-bootstrap-4.css" />

<div class="container">
  <div class="row">
    <div class="col-sm-6">
      <input type="text" class="form-control datetimepicker-input" id="datetimepicker5" data-toggle="datetimepicker" data-target="#datetimepicker5" />
    </div>
    <script type="text/javascript">
      $(function() {
        $('#datetimepicker5').datetimepicker();
      });
    </script>
  </div>
</div>

于 2019-08-08T07:30:07.643 回答