1、修复默认第一次进来点击当前月份天数不对
在创建html的函数里面
buildHTml: function() {
// 1、 获取当前月天数, 注意:下面的遍历index是0开始,所以在后面减1
var currentMonthTotalDay = new Date(year, month, 0).getDate() - 1;
// 2、在创建天数的循环逻辑判断一下当前月份天数即可
if (sjObj.opt.Day) sjObj.opt.timeElm.find("[data-class='dd'] .df-li").each(function(index, element) {
if (parseInt($(this).attr("data-val")) == parseInt(day)) {
var pY = -($(this).index() - 2) * sjObj.opt.height;
// console.log(day)
$(this).parent().css({
"transform": "translate(0," + pY + "px)"
})
}
if (currentMonthTotalDay < index) { // 判断当月天数
$(this).removeClass("df-show").addClass("df-hide");
}
})
}2、修复部分安卓设备显示不居中
修改shijian.css的.df-box新增对WebKit内核做移动兼容
-webkit - transform: translate(-50 % , -50 % );
.df - box {
min - width: 170 px;
background: #fff;
border - radius: 10 px;
font - size: 12 px;
text - shadow: none; -
webkit - box - sizing: border - box; -
moz - box - sizing: border - box;
box - sizing: border - box;
z - index: 2;
position: absolute; -
webkit - user - select: none; -
moz - user - select: none; -
ms - user - select: none; -
ms - touch - action: none;
overflow: hidden;
text - align: center; -
webkit - tap - highlight - color: rgba(0, 0, 0, 0);
top: 50 % ;
left: 50 % ; -
webkit - transform: translate(-50 % , -50 % );
transform: translate(-50 % , -50 % );
}