下面通过webpacker处理的javascript正在使用正确的startDate设置UI(假设今天是2020-12-19:2018-12-19),但不是endDate,如图所示
2020-12-19
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],{
/***/ "./app/javascript/src/promotion_datespan.js":
/*!**************************************************!*\
!*** ./app/javascript/src/promotion_datespan.js ***!
\**************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function($) {$(function () {
var startDate = new Date();
startDate.setFullYear(startDate.getFullYear() - 2);
$('#date_from').fdatepicker({
initialDate: startDate,
format: 'yyyy-mm-dd',
disableDblClickSelection: true,
leftArrow: '<<',
rightArrow: '>>',
closeIcon: 'X',
closeButton: true
});
});
$(function () {
var endDate = new Date();
endDate.getDate(endDate.getDate() - 2);
$('#date_to').fdatepicker({
initialDate: endDate,
format: 'yyyy-mm-dd',
disableDblClickSelection: true,
leftArrow: '<<',
rightArrow: '>>',
closeIcon: 'X',
closeButton: true
});
});
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery/src/jquery */ "./node_modules/jquery/src/jquery.js")))
/***/ })
}]);
//# sourceMappingURL=0-0fcba24322adb18c7ad0.chunk.js.map
getDate
返回错误的数据?