Url:http://zjingwen.github.io/settimeoutgoblog/funui/fundate/index.html (if open too slow, or can't open, reason you know.) )
first, the idea 1, make calendar This UI component, we need to get the first step is the data, we need to know for example today belongs, that year, that January, the day of the week. 2, the presentation of the data should be what it looks like, in order to make this for example, rational analysis, take the diagram as an example, 6x7 lattice, we want to get 42 data, where the month data account for the middle of the array, the next month data account for the tail of the array, the data accounted for the array of the head. So the question is, how many days will it take to figure out what the last one months are. The solution, judging, last one months is the day of the week, June the last month of May is Sunday, so that we can reverse the reduction of the way to get. If the last day of January is Saturday, then we need 6 days to populate the data. Using this method to populate the data is a good way to look at it.
It would be nice to push the data of the month directly into the array. Next month data, after the first two data push, judging the length of the array, to loop push the next month's data, such a calendar of data, we are all filled into an array, the length of the data 42. Looping through a one-dimensional array is cumbersome. We need to convert this one-dimensional array to a two-dimensional array so that it is easy to output. With a one-dimensional array is not not possible, we need to use CSS to control the number of rows, so I do not like, I like the component is, the CSS all stripped, still can run out of effect. A nested loop is used to solve the problem. The outer is 6 and the inner layer is 7.
From for notes (Wiz)
Using avalon+ native JS to make a calendar space (i)