Skip to content

Schema 组件

Component

所有组件的基类。

命名空间

php
Lartrix\\Schema\\Components\\Component

通用方法

方法参数说明
make($text = null)string创建组件实例
props(array $props)array设置属性
children($children)arraystring
on($event, $handler)string, array绑定事件
slot($name, $content)string, array定义插槽
if($condition)stringv-if 条件
show($condition)stringv-show 条件
for($expression, $key = null)string, stringv-for 循环
model($path)stringarray
data(array $data)array设置响应式数据
methods(array $methods)array设置方法
onMounted($actions)array挂载回调

转换方法

方法说明
toArray()转为数组
toJson()转为 JSON
build()构建完整 Schema

NaiveUI 组件

Button

按钮组件。

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

Button::make('文本')
    ->type('primary')
    ->size('large')
    ->on('click', [...]);

Input

输入框组件。

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

Input::make()
    ->props(['placeholder' => '提示'])
    ->model('form.name');

Select

选择器组件。

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

Select::make()
    ->options([
        ['label' => '选项1', 'value' => 1],
    ])
    ->model('form.status');

SwitchC

开关组件(Switch 是 PHP 保留字)。

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

SwitchC::make()
    ->props(['checkedValue' => true])
    ->model('form.status');

Card

卡片组件。

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

Card::make()
    ->title('标题')
    ->children([...]);

Form / FormItem

表单组件。

php
use Lartrix\\Schema\\Components\\NaiveUI\\{Form, FormItem};

Form::make()
    ->model('formData')
    ->children([
        FormItem::make('标签', 'name')
            $table->child(Input::make()),
    ]);

模态框组件。

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

Modal::make()
    ->show('visible')
    ->on('update:show', SetAction::make('visible', '{{ $event }}'))
    ->children([...]);

Drawer

抽屉组件。

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

Drawer::make()
    ->show('drawerVisible')
    ->props(['title' => '详情'])
    ->children([...]);

Table

表格组件。

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

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

业务组件

CrudPage

CRUD 页面组件。

php
use Lartrix\\Schema\\Components\\Business\\CrudPage;

CrudPage::make('标题')
    ->apiPrefix('/api/users')
    ->columns([...])
    ->search([...])
    ->toolbarLeft([...]);

OptForm

操作表单组件。

php
use Lartrix\\Schema\\Components\\Business\\OptForm;

OptForm::make('formData')
    $table->fields([
        ['标签', 'name', Input::make()],
    ])
    $table->buttons([...]);

MarkdownEditor

Markdown 编辑器。

php
use Lartrix\\Schema\\Components\\Business\\MarkdownEditor;

MarkdownEditor::make()
    ->model('form.content');

RichEditor

富文本编辑器。

php
use Lartrix\\Schema\\Components\\Business\\RichEditor;

RichEditor::make()
    ->model('form.content');

基于 MIT 许可发布