Skip to content
目录

Switch

开关组件。

样式

除支持 通用布局样式通用视图样式 以外,还支持以下样式:

属性名类型默认值说明示例
onColorstring系统默认打开时的颜色onColor: '#FF0000'
offColorstring系统默认关闭时的颜色offColor: '#999999'
thumbColorstring系统默认滑块颜色thumbColor: '#0000FF'

属性

除支持 通用视图属性 以外,还支持以下属性:

属性名类型默认值说明示例
checkedbooleanfalse是否打开this.checked = true;

事件

事件名类型说明
switchSwitchEvent选择事件

示例

js
let switch = new Switch();
switch.checked = true;
switch.addEventListener('switch', (event) => {
    console.log("switch state:" + event.state);
});