getTime(week) {
                let time;
                let year = new Date().getFullYear();
                let d = new Date(year, 0, 1);
                while (d.getDay() != 1) {
                    d.setDate(d.getDate() + 1);
                }
                let to = new Date(year + 1, 0, 1);
                let i = 1;
                for (var from = d; from < to;) {
                    if (i > 1) {
                        from.setDate(from.getDate() + 7);
                    }
                    if (from < to) {
                        from.setDate(from.getDate());
                    }
                    console.log(year + "年第" + i + "" + (from.getMonth() + 1) + "" + from.getDate() + "日 - ")

                    if (i === week) {
                        time = `${year}-${from.getMonth() + 1}-${from.getDate()}`
                    }
                    i++;

                }
                return time
            }

 

posted on 2021-10-27 17:05  去你的未来  阅读(38)  评论(0编辑  收藏  举报