mirror of
https://gitee.com/layui/layui.git
synced 2026-01-28 19:11:26 +08:00
feat(laydate): 新增 cellRender 选项,用于自定义单元格内容 (#1843)
* feat(laydate): 新增 cellRender 选项,用于自定义单元格内容 * docs(laydate): 添加 cellRender 文档 * chore: 调整示例顺序 * chore: 采用 stackblitz 原示例,提升扩展内容的丰富性 注: HTML 出现换行且缩进,会被 markdown 解析器解析为 code,因此删除了换行和最外层缩进 * chore: 注释示例中的若干选项 * chore: 解除若干选项的注释 * chore: 改进 cellRender 文档示例的可读性 * refactor(laydate): cellRender 第一个参数由数组改为对象 * docs(laydate): 改进 cellRender 文档可读性 --------- Co-authored-by: 贤心 <3277200+sentsim@users.noreply.github.com>
This commit is contained in:
@@ -79,7 +79,6 @@
|
||||
</textarea>
|
||||
</pre>
|
||||
|
||||
|
||||
<h3 id="demo-theme" lay-toc="{level: 2, hot: true}">自定义主题</h3>
|
||||
|
||||
<pre class="layui-code" lay-options="{preview: true, codeStyle: 'height: 535px;', layout: ['preview', 'code'], tools: ['full']}">
|
||||
@@ -88,10 +87,18 @@
|
||||
</textarea>
|
||||
</pre>
|
||||
|
||||
<h3 id="demo-static" lay-toc="{level: 2}">直接静态显示</h3>
|
||||
<h3 id="demo-static" lay-toc="{level: 2}">静态显示</h3>
|
||||
|
||||
<pre class="layui-code" lay-options="{preview: true, codeStyle: 'height: 535px;', layout: ['preview', 'code'], tools: ['full']}">
|
||||
<textarea>
|
||||
{{- d.include("/laydate/examples/static.md") }}
|
||||
</textarea>
|
||||
</pre>
|
||||
</pre>
|
||||
|
||||
<h3 id="demo-custom-cell" lay-toc="{level: 2}">扩展农历 🔥</h3>
|
||||
|
||||
<pre class="layui-code" lay-options="{preview: 'iframe', style: 'height: 385px;', codeStyle: 'height: 535px;', layout: ['preview', 'code'], tools: ['full']}">
|
||||
<textarea>
|
||||
{{- d.include("/laydate/examples/cell.md") }}
|
||||
</textarea>
|
||||
</pre>
|
||||
|
||||
@@ -715,6 +715,29 @@ holidays: function (ymd, render) {
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>cellRender <sup>2.9.9+</sup></td>
|
||||
<td>
|
||||
|
||||
自定义单元格内容。
|
||||
|
||||
```
|
||||
cellRender: function(ymd, render, info){
|
||||
var y = ymd.year;
|
||||
var m = ymd.month;
|
||||
var d = ymd.date;
|
||||
|
||||
// 面板类型 'year' | 'month' | 'date'
|
||||
if(info.type === 'date'){
|
||||
render(d); // 参数为 string, HTMLElement, JQuery 类型
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</td>
|
||||
<td>function</td>
|
||||
<td> - </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" style="text-align: center">
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user