我正在尝试在Thymeleaf中运行一个JS脚本,但它不起作用。在浏览器中我收到此错误:
Uncaught TypeError: $(...).datepicker is not a function
at HTMLDocument.<anonymous> (3:117)
at j (jquery-3.2.1.slim.min.js:2)
at k (jquery-3.2.1.slim.min.js:2)
JS脚本:
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script th:inline="javascript">
$(function() {
$("#datebirth").datepicker({
maxDate:'0'
});
} );
</script>
冲突在哪里?
答案 0 :(得分:0)
请检查此Thymeleaf tutorial以使用脚本内联。
举个例子,你可以尝试:
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript" th:inline="javascript">
/*<![CDATA[*/
$(function() {
$("#datebirth").datepicker({
maxDate:'0'
});
});
/*]]>*/
</script>