Skip to content

数据展示组件

Table 表格

php
use Lartrix\\Schema\\Components\\NaiveUI\\Table;

Table::make()
    ->props([
        'data' => '{{ list }}',
        'columns' => [
            ['title' => 'ID', 'key' => 'id'],
            ['title' => '名称', 'key' => 'name'],
            ['title' => '状态', 'key' => 'status'],
        ],
    ]);

带操作列

php
Table::make()
    ->props([
        'data' => '{{ list }}',
        'columns' => [
            ['title' => 'ID', 'key' => 'id'],
            ['title' => '名称', 'key' => 'name'],
            [
                'title' => '操作',
                'key' => 'actions',
                'render' => [
                    Button::make('编辑')->type('primary'),
                    Button::make('删除')->type('error'),
                ],
            ],
        ],
    ]);

Props

属性类型说明
dataarray表格数据
columnsarray列配置
borderedboolean显示边框
stripedboolean斑马纹
singleLineboolean单行显示
sizestring尺寸:small, medium, large
loadingboolean加载状态
paginationobject/boolean分页配置
scrollXnumber横向滚动宽度
maxHeightnumber最大高度

List 列表

php
use Lartrix\\Schema\\Components\\NaiveUI\\ListC;

ListC::make()
    ->props([
        'data' => '{{ list }}',
    ]);

Tree 树形控件

php
use Lartrix\\Schema\\Components\\NaiveUI\\Tree;

Tree::make()
    ->props([
        'data' => [
            [
                'label' => '根节点',
                'key' => 'root',
                'children' => [
                    ['label' => '子节点1', 'key' => 'child1'],
                    ['label' => '子节点2', 'key' => 'child2'],
                ],
            ],
        ],
    ]);

Props

属性类型说明
dataarray树形数据
checkableboolean显示复选框
selectableboolean可选择
expandedKeysarray展开的节点
checkedKeysarray选中的节点
defaultExpandAllboolean默认展开所有
keyFieldstring节点 key 字段,默认 'key'
labelFieldstring节点标签字段,默认 'label'
childrenFieldstring子节点字段,默认 'children'

TreeSelect 树形选择

php
use Lartrix\\Schema\\Components\\NaiveUI\\TreeSelect;

TreeSelect::make()
    ->props([
        'options' => [...],
    ]);

Props

属性类型说明
optionsarray选项数据
multipleboolean多选
checkableboolean显示复选框
cascadeboolean级联选择
checkStrategystring选择策略:all, parent, child
placeholderstring占位符
clearableboolean可清空
filterableboolean可搜索

Badge 徽标

php
use Lartrix\\Schema\\Components\\NaiveUI\\Badge;

Badge::make()
    ->props(['value' => 5])
    ->children([
        Button::make('消息'),
    ]);

Tag 标签

php
use Lartrix\\Schema\\Components\\NaiveUI\\Tag;

Tag::make()->type('success')->children(['成功']);
Tag::make()->type('warning')->children(['警告']);
Tag::make()->type('error')->children(['错误']);

Avatar 头像

php
use Lartrix\\Schema\\Components\\NaiveUI\\Avatar;

Avatar::make()
    ->props([
        'src' => '{{ user.avatar }}',
        'fallbackSrc' => '/default-avatar.png',
    ]);

Progress 进度条

php
use Lartrix\\Schema\\Components\\NaiveUI\\Progress;

Progress::make()
    ->props([
        'percentage' => 50,
        'status' => 'success',
    ]);

基于 MIT 许可发布