Add a method to set the start of a week in the layDate component of layui

Release: 2019-11-23 15:53:26
forward
3540 people have browsed it

Add a method to set the start of a week in the layDate component of layui

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:

Add a method to set the start of a week in the layDate component of layui

#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

Add a method to set the start of a week in the layDate component of layui

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

Add a method to set the start of a week in the layDate component of layui3. 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

Add a method to set the start of a week in the layDate component of layuiThe other one is the content in the actual td

Add a method to set the start of a week in the layDate component of layuiNow 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

Add a method to set the start of a week in the layDate component of layui

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!

Related labels:
source:layui.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template