Using avalon+ native JS to make a calendar space (i)

Source: Internet
Author: User
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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.