mirror of
https://gitee.com/layui/layui.git
synced 2026-01-28 19:11:26 +08:00
feat(laydate): 新增 formatToDisplay 选项 (#1788)
* feat(laydate): 新增 formatToDisplay 选项 * docs(laydate): 更新 formatToDisplay 文档 * docs(laydate): 优化 `formatToDisplay` 选项的示例代码,以便更直观 * chore: 修改注释词汇,以避免引起不必要的安全性争议 --------- Co-authored-by: 贤心 <3277200+sentsim@users.noreply.github.com>
This commit is contained in:
@@ -170,6 +170,29 @@ format: '北京时间 H 点 m 分'
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>formatToDisplay <sup>2.9.9+</sup></td>
|
||||
<td>
|
||||
|
||||
仅用于格式化日期显示的格式,不影响日期值
|
||||
|
||||
```
|
||||
formatToDisplay: function (value) {
|
||||
// value - 日期字符串
|
||||
var date = new Date(value);
|
||||
var displayValue = [
|
||||
value,
|
||||
date.toLocaleDateString(Intl.LocalesArgument, { weekday: 'long' })
|
||||
].join(' ');
|
||||
return displayValue;
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
</td>
|
||||
<td>function</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
[value](#options.value)
|
||||
|
||||
Reference in New Issue
Block a user