列表项 item
item 将一项数据、属性和子节点交给父节点。在按钮组中它会生成按钮,在章节列表中它会生成章节。
用法
以工具栏 toolbar 部件为例,其 onBuildItem() 方法将 item 部件渲染为按钮、链接或分隔线。
php
toolbar
(
item(set(
[
'text' => '导出',
'icon' => 'export',
'class' => 'ghost text-darker',
'url' => '/project-export.html',
])),
item(set::type('divider')),
item(set(
[
'text' => '创建项目',
'icon' => 'plus',
'class' => 'btn primary',
'url' => '/project-create.html'
])),
);方法
build()
构建时如果父节点实现了 onBuildItem($item),会调用该方法并使用其返回值。其余情况按普通节点构建子内容。
使用 item() 的部件包括 nav、btnGroup、toolbar、sectionList 和 tableData。