Skip to content

基础组件

Button 按钮

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

// 基础按钮
Button::make('按钮文本');

// 主要按钮
Button::make('保存')->type('primary');

// 危险按钮
Button::make('删除')->type('error');

// 带图标
Button::make('新增')->props(['icon' => 'add']);

// 加载状态
Button::make('保存')
    $table->loading('{{ saving }}')
    ->on('click', [...]);

Props

属性类型说明
typestring类型:default, primary, info, success, warning, error
sizestring尺寸:tiny, small, medium, large
disabledboolean禁用
loadingboolean加载状态
iconstring图标
blockboolean块级按钮
ghostboolean幽灵按钮
dashedboolean虚线边框
roundboolean圆角
circleboolean圆形

Input 输入框

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

// 基础输入框
Input::make();

// 带占位符
Input::make()->props(['placeholder' => '请输入']);

// 可清空
Input::make()->props(['clearable' => true]);

// 密码输入
Input::make()->props(['type' => 'password']);

// 多行文本
Input::make()->props(['type' => 'textarea', 'rows' => 4]);

// 双向绑定
Input::make()->model('formData.name');

Props

属性类型说明
typestring类型:text, password, textarea, number
placeholderstring占位符
clearableboolean可清空
disabledboolean禁用
readonlyboolean只读
maxlengthnumber最大长度
showCountboolean显示字数统计
rowsnumber行数(textarea)

Select 选择器

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

// 基础选择器
Select::make()
    ->props([
        'options' => [
            ['label' => '选项1', 'value' => 1],
            ['label' => '选项2', 'value' => 2],
        ],
    ]);

// 使用 options 方法
Select::make()
    ->options([
        ['label' => '启用', 'value' => 1],
        ['label' => '禁用', 'value' => 0],
    ]);

// 多选
Select::make()
    ->options([...])
    ->props(['multiple' => true]);

// 可搜索
Select::make()
    ->options([...])
    ->props(['filterable' => true]);

// 双向绑定
Select::make()->options([...])->model('formData.status');

Props

属性类型说明
optionsarray选项列表
multipleboolean多选
clearableboolean可清空
filterableboolean可搜索
placeholderstring占位符
disabledboolean禁用

Switch 开关

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

// 基础开关
SwitchC::make();

// 设定值
SwitchC::make()
    ->props([
        'checkedValue' => true,
        'uncheckedValue' => false,
    ]);

// 文字显示
SwitchC::make()
    ->props([
        'checkedText' => '启用',
        'uncheckedText' => '禁用',
    ]);

// 双向绑定
SwitchC::make()->model('formData.status');

Card 卡片

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

Card::make()
    ->title('卡片标题')
    ->children([
        // 卡片内容
        Input::make(),
        Button::make('保存'),
    ]);

Props

属性类型说明
titlestring标题
sizestring尺寸:small, medium, large, huge
hoverableboolean悬停效果
embeddedboolean嵌入式
segmentedboolean分段

基于 MIT 许可发布