ios日历显示问题,真机调试没问题,上传之后扫码之后日历的日期部分无法显示,安卓没问题~
日历代码:
<view class=‘date-box’>
<block wx:for=’{{dateArr}}’ wx:key=’’>
<view class=’{{isToday == item.isToday ? “nowDay” : “”}}’ >
<view class=‘date-head {{selectnum == item.dateNum ? “select” :""}}’ bindtap=‘lookHuoDong’ data-year=’{{year}}’ data-month=’{{month}}’ data-datenum=’{{item.dateNum}}’ bindtap=‘updataList’>
<view>{{item.dateNum}}</view>
</view>
</view>
</block>
</view>
js:
dateInit: function (setYear, setMonth) {
//全部时间的月份都是按0~11基准,显示月份才+1
let dateArr = []; //需要遍历的日历数组数据
let arrLen = 0; //dateArr的数组长度
let now = setYear ? new Date(setYear, setMonth) : new Date();
let year = setYear || now.getFullYear();
let nextYear = 0;
let month = setMonth || now.getMonth(); //没有+1方便后面计算当月总天数
let nextMonth = (month + 1) > 11 ? 1 : (month + 1);
let startWeek = new Date(year + ‘,’ + (month + 1) + ‘,’ + 1).getDay(); //目标月1号对应的星期
let dayNums = new Date(year, nextMonth, 0).getDate(); //获取目标月有多少天
let obj = {};
let num = 0;
if (month + 1 > 11) {
nextYear = year + 1;
dayNums = new Date(nextYear, nextMonth, 0).getDate();
}
arrLen = startWeek + dayNums;
for (let i = 0; i < arrLen; i++) {
if (i >= startWeek) {
num = i - startWeek + 1;
obj = {
isToday: ‘’ + year + (month + 1) + num,
dateNum: num,
weight: 5
}
} else {
obj = {};
}
dateArr[i] = obj;
}
this.setData({
dateArr: dateArr
})
let nowDate = new Date();
let nowYear = nowDate.getFullYear();
let nowMonth = nowDate.getMonth() + 1;
let nowWeek = nowDate.getDay();
let getYear = setYear || nowYear;
let getMonth = setMonth >= 0 ? (setMonth + 1) : nowMonth;
if (nowYear == getYear && nowMonth == getMonth) {
this.setData({
isTodayWeek: true,
todayIndex: nowWeek
})
} else {
this.setData({
isTodayWeek: false,
todayIndex: -1
})
}
console.log(new Date(year, nextMonth, 0).getDate(),dateArr, arrLen, now, year, month, nextMonth, startWeek)
},
麻烦提供出现问题的机型和微信版本,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)