ios - React-native 函数在调试模式下工作但不在发布模式下
问题描述
我厌倦了一整天来解决这个问题,下面的函数不能在发布模式下工作,但它正在调试模式下工作。它应该返回日期范围。
import moment from 'moment';
this.state = {
startDate: '01-01-2019',
endDate: '02-02-2019'
};
getArr(checkedWeekDay) {
const { endDate, startDate } = this.state;
const dateRange = [];
const endOfRange = moment(endDate).endOf('month');
const startOfRange = moment(startDate).startOf('month').day(checkedWeekDay);
const S = 7;
const O = 1;
if (startOfRange.date() > S) startOfRange.add(S, 'days');
for (let $index = startOfRange; $index < endOfRange; $index.add(O, 'M')) {
const startOfIndex = moment($index).startOf('month').day(checkedWeekDay);
if (startOfIndex.date() > S) startOfIndex.add(S, 'days');
const startIndex = startOfIndex.clone();
while (startOfIndex.month() === startIndex.month()) {
if (startIndex >= moment(startDate) && startIndex <= moment(endDate)) {
dateRange.push(startIndex.format('YYYY-MM-DD'));
}
startIndex.add(S, 'days');
}
}
return dateRange;
}
this.getArr(5);
结果应该如下,
["2019-01-04", "2019-01-11", "2019-01-18", "2019-01-25", "2019-02-01"]
解决方案
推荐阅读
- javascript - 使用存储在数组中的 JS 颜色值来设置 P5.js Dom 元素的样式
- python - 为 url 目的生成看似随机的唯一数字
- amazon-web-services - VPC 中的 Lambda 如何连接到 Cloudsearch?
- connman - 使用第一个字段而不是第二个字段连接到 connman 服务
- android - Activity recreate() 后 ProgressBar setProgress() 不起作用
- node.js - 使用 websockets 构建可扩展的 SPA,它有多复杂?
- google-cloud-storage - What is the difference between V4 and V2 Signing Process for Google Cloud Storage's Resources?
- excel - Excel 输入日期显示不正确
- python - 最小化功能
- json - json_decode 变量到电子邮件