It is international practice that Sunday is the beginning of the week, but some users still prefer Monday as the beginning of the week. However, currently there is no configuration item for laydate to determine this. A configuration item support has been added to laydatePro as follows:
#You can also see from the comments that for ease of use, you can set 0 to 6 (that is, Date. In addition to the value corresponding to getDay()), it also provides the corresponding days one, two, three or Su, Mo, Tu. Recommended:layui framework quick start
The following is a brief introduction to the implementation logic behind it:
1. Add an initial value of weekStart to the default config
2. When rendering, use a regular expression to check whether the filled in value meets the requirements. If it meets the requirements, set it to the corresponding 0-6. If it does not meet the requirement, reset it to 0
3. When the laydate is actually rendered later, nodes will be generated based on weekStart
There are two parts here, one is the one displayed on th in the table header
The other one is the content in the actual td
Now we have changed the setting of the start of the week. The example gives the start of Monday. This is actually more common. But it’s not just Monday that can be set. In fact, it supports setting any day as the start, and then you can set it according to actual needs
The above is the detailed content of Add a method to set the start of a week in the layDate component of layui. For more information, please follow other related articles on the PHP Chinese website!