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:
morning-star
2024-04-24 17:48:01 +08:00
committed by GitHub
parent f1f0575d15
commit c855d8b19b
2 changed files with 62 additions and 1 deletions

View File

@@ -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)