[英]TypeError: $(…).datetimepicker is not a function
I know this question was asked many times before (because I looked here for solution), so excuse me for adding more trash. 我知道这个问题以前被问过很多次了(因为我在这里找到了解决方案),所以请原谅我添加了更多垃圾。 I'm using this datetime picker and in the console I get error:
我正在使用此日期时间选择器,并且在控制台中出现错误:
TypeError: $(...).datetimepicker is not a function
Whole HTML document: 整个HTML文件:
<html>
<head>
<link rel="stylesheet" type="text/css" href="./css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="./css/bootstrap-datetimepicker.css">
<link rel="stylesheet" type="text/css" href="./css/fontawesome.css">
<link rel="stylesheet" type="text/css" href="./css/style.css">
<script src="./js/jquery.js"></script>
<script src="./js/moment.js"></script>
<script src="./js/bootstrap.js"></script>
<script src="./js/bootstrap-datetimepicker.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<div class="input-group date" id="datetimepicker2" data-target-input="nearest">
<input type="text" class="form-control datetimepicker-input" data-target="#datetimepicker2"/>
<div class="input-group-append" data-target="#datetimepicker2" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
$('#datetimepicker2').datetimepicker({
locale: 'ru'
});
});
</script>
</div>
</div>
</body>
</html>
I don't think it's the order of loading scripts (as mentioned everywhere else) and I have all the dependencies. 我不认为这是加载脚本的顺序(在其他地方都提到过),并且我拥有所有依赖项。 What could be the cause of error?
错误原因可能是什么?
Check sequence of js import 检查js导入的顺序
tempus dominus with bootstrap 4: 使用引导程序4的tempus dominus:
$(function() { $('#datetimepicker1').datetimepicker(); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment-with-locales.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script> <script src="https://rawgit.com/tempusdominus/bootstrap-4/master/build/js/tempusdominus-bootstrap-4.js"></script> <link href="https://rawgit.com/tempusdominus/bootstrap-4/master/build/css/tempusdominus-bootstrap-4.css" rel="stylesheet"/> <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/> <div class="container"> <div class="row"> <div class="col-sm-6"> <div class="form-group"> <div class="input-group date" id="datetimepicker1" data-target-input="nearest"> <input type="text" class="form-control datetimepicker-input" data-target="#datetimepicker1" /> <span class="input-group-addon" data-target="#datetimepicker1" data-toggle="datetimepicker"> <span class="fa fa-calendar"></span> </span> </div> </div> </div> </div> </div>
tether.min.js
also required for tempusdominus-bootstrap-4.js
tether.min.js
tempusdominus-bootstrap-4.js
也需要tempusdominus-bootstrap-4.js
tempus dominus with bootstrap 3 (Run in full page mode or set css) 使用引导程序3的tempus dominus(以整页模式运行或设置CSS)
$(function() { $('#datetimepicker1').datetimepicker(); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment-with-locales.min.js"></script> <script src="https://rawgit.com/tempusdominus/bootstrap-3/master/build/js/tempusdominus-bootstrap-3.js"></script> <link href="https://rawgit.com/tempusdominus/bootstrap-3/master/build/css/tempusdominus-bootstrap-3.css" rel="stylesheet"/> <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <div class="container"> <div class="row"> <div class="col-sm-6"> <div class="form-group"> <div class="input-group date" id="datetimepicker1" data-target-input="nearest"> <input type="text" class="form-control datetimepicker-input" data-target="#datetimepicker1" /> <span class="input-group-addon" data-target="#datetimepicker1" data-toggle="datetimepicker"> <span class="glyphicon glyphicon-calendar"></span> </span> </div> </div> </div> </div> </div>
Hope this will helps you 希望这对您有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.