我是前端开发的新手,我正在尝试添加日期选择器( Materialize framework )。我花了很多时间在网上搜索
“如何添加实体化日期选择器”。
但我无法找到解决问题的方法。
<html>
<head>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-
beta/css/materialize.min.css">
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<input type="text" class="datepicker">
<!--JavaScript at end of body for optimized loading-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/js/materialize.min.js"></script>
<script
src="http://code.jquery.com/jquery-3.3.1.js"
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.datepicker');
var instances = M.Datepicker.init(elems, options);
});
// Or with jQuery
$(document).ready(function(){
$('.datepicker').datepicker();
});
</script>
</body>
</html>
答案 0 :(得分:2)
// Using with jQuery
$(document).ready(function(){
$('.datepicker').datepicker();
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
=<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css">
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/js/materialize.min.js"></script>
<body>
<input type="text" class="datepicker">
</body>
&#13;
我建议您在HTML中第一次导入jquery
,然后然后 materiliaze.js
,如上所示
答案 1 :(得分:0)
使用此主题作为基本主题,大多数组件都具有物化触感。 https://materializecss.com/pickers.html
检查他们的演示。
答案 2 :(得分:0)
这是你的问题。
<input type="text" class="datepicker">
将输入类型更改为“日期”。