我使用npm安装daterangepicker,但无法使用
此命令
npm install daterangepicker
这是我的代码
create.blade.php
<input type="text" class="form-control is-invalid" name="period_date" required>
$('input[name="period_date"]').daterangepicker();
app.js
window.moment = require('moment');
window.daterangepicker = require('daterangepicker');
这是结果
点击输入日期范围选择器后的答案 0 :(得分:0)
JQuery应该在脚本标签之间设置。下面的示例:
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
<input type="text" name="daterange" value="01/01/2018 - 01/15/2018" />
<script>
$(function() {
$('input[name="daterange"]').daterangepicker({
opens: 'left'
}, function(start, end, label) {
console.log("A new date selection was made: " + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
});
});
</script>
答案 1 :(得分:0)
这是我的答案
在文件.. \ resources \ sass \ app.scss
中应导入.css
//Daterangepicker
@import "~daterangepicker/daterangepicker.css";
导入后运行
npm run dev
信用:Medium