Please give me a best practice. I’m not familiar with moment (I’ve been looking at the API for a day and I understand the basics). I don’t want to take the wrong path. Please give me the final data structure , such as [[ 26,27,28,1,2,3,4], [], [], ...]
Thank you, woohaha
There seems to be no method to directly generate a calendar in the moment.js API
General idea:
Construct a 6*7 array daysArr
Get the number of days in the previous month, the number of days in this month, and the day of the week corresponding to the first of this month (0 means Monday)
Then calculate the corresponding date
daysArr[0][0]
(the number of days in the previous month - the week corresponding to the first of this month)Calculate the values of other elements of daysArr based on
daysArr[0][0]
One-dimensional date array can be thought of as follows: