我有一个.hbs模板,我需要添加date-time
选择器小部件。
以下是我目前拥有的:
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.js"
integrity="sha512-+k1pnlgt4F1H8L7t3z95o3/KO+o78INEcXTbnoJQ/F2VqDVhWoaiVml/OEHv9HsVgxUaVW+IbiZPUJQfF/YxZw=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.full.js"
integrity="sha512-+UiyfI4KyV1uypmEqz9cOIJNwye+u+S58/hSwKEAeUMViTTqM9/L4lqu8UxJzhmzGpms8PzFJDzEqXL9niHyjA=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.css"
integrity="sha512-bYPO5jmStZ9WI2602V2zaivdAnbAhtfzmxnEGh9RwtlI00I9s8ulGe4oBa5XxiC6tCITJH/QG70jswBhbLkxPw=="
crossorigin="anonymous" referrerpolicy="no-referrer"/>
</head>
<body>
<input id="date_timepicker_start" type="text" >
<input id="date_timepicker_end" type="text" >
<script src="/javascripts/datetime.js"></script>
</body>
字符串
在这个脚本datetime.js
中,我有以下一行:
$(document).ready(function(){
$('#date_timepicker_start').datetimepicker({ ... });
});
型
当我加载我的页面时,我得到:
jquery.js:3793 Uncaught TypeError: $(...).datetimepicker is not a function
at HTMLDocument.<anonymous> (datetime.js:2:33)
at mightThrow (jquery.js:3489:29)
at process (jquery.js:3557:12)
型
现在,为什么会这样呢?jQuery
肯定加载良好,我可以使用alert
为例,以确认它加载。为什么不使用datetimepicker
?
1条答案
按热度按时间7kjnsjlb1#
我做了一个片段来展示你的代码是完美的,也许检查你的网络选项卡为什么datetimepicker.js没有加载,至少在这里它是这样的:
字符串