主题
Boolean 组件
该组件实际就是 Switch
组件
好的,以下是将方法名替换为中文说明后的 Switches
类方法文档:
方法
设置禁用状态
php
$this->disabled(true);
参数说明:
bool $disabled
: 如果为true
,则禁用开关;如果为false
,则启用开关。
设置宽度
php
$this->width(100);
参数说明:
float $width
: 指定开关的宽度,以像素为单位。
设置打开时图标类名
php
$this->activeIconClass('icon-active');
参数说明:
string $activeIconClass
: 开关打开时的图标类名。设置此项会忽略active-text
。
设置关闭时图标类名
php
$this->inactiveIconClass('icon-inactive');
参数说明:
string $inactiveIconClass
: 开关关闭时的图标类名。设置此项会忽略inactive-text
。
设置打开时文字描述
php
$this->activeText('开启');
参数说明:
string $activeText
: 开关打开状态时显示的文字。
设置关闭时文字描述
php
$this->inactiveText('关闭');
参数说明:
string $inactiveText
: 开关关闭状态时显示的文字。
设置打开时的值
php
$this->activeValue('on');
参数说明:
string $activeValue
: 开关打开状态时的值。
设置关闭时的值
php
$this->inactiveValue('off');
参数说明:
string $inactiveValue
: 开关关闭状态时的值。
设置打开时背景色
php
$this->activeColor('#00FF00');
参数说明:
string $activeColor
: 开关打开状态时的背景颜色。
设置关闭时背景色
php
$this->inactiveColor('#FF0000');
参数说明:
string $inactiveColor
: 开关关闭状态时的背景颜色。
设置 name 属性
php
$this->name('switch_name');
参数说明:
string $name
: 开关的name
属性值。