ui.Switch
# ui.Switch
返回一个切换按钮。
函数 | 返回值 |
---|---|
ui.Switch(value, onChange, disabled, style) | Object |
参数 | 类型 | 说明 |
---|---|---|
value | Boolean | 当前显示值 |
onChange | Function | 选择不同值时触发的方法 |
disabled | Boolean | 切换按钮是否禁用 |
style | Object | 组件样式 |
# setValue
设置当前显示值。
函数 | 返回值 |
---|---|
setValue(value) | ui.Switch |
参数 | 类型 | 说明 |
---|---|---|
value | Boolean | 当前显示值 |
# getValue
返回当前显示值。
函数 | 返回值 |
---|---|
getValue() | Boolean |
# setDisabled
设置切换按钮是否禁用。
函数 | 返回值 |
---|---|
setDisabled(disable) | ui.Switch |
参数 | 类型 | 说明 |
---|---|---|
disable | Boolean | 切换按钮是否禁用 |
# getDisabled
返回切换按钮是否禁用。
函数 | 返回值 |
---|---|
getDisabled() | Boolean |
# setStyle
设置Switch样式。
函数 | 返回值 |
---|---|
setStyle(style) | ui.Switch |
参数 | 类型 | 说明 |
---|---|---|
style | Object | Switch样式 |
# getStyle
返回Switch样式。
函数 | 返回值 |
---|---|
getStyle() | Object |
# onChange
点击切换按钮回调方法。
函数 | 返回值 |
---|---|
onChange(callback) | Object |
参数 | 类型 | 说明 |
---|---|---|
callback | Function | 切换按钮回调方法 |
/**
* @File : ui.Switch
* @Time : 2021/3/23
* @Author : piesat
* @Version : 1.0
* @Contact : 400-890-0662
* @License : (C)Copyright 航天宏图信息技术股份有限公司
* @Desc : 开关组件示例
*/
function funSwitch(value) {
print("切换的数据为:" + value);
}
var switch1 = ui.Switch({
value: false,
onChange: funSwitch,
});
var switchName = ui.Label("是否开启:");
var switchPanel = ui.Panel({
widgets: [switchName, switch1],
layout: ui.Layout.flow("horizontal"),
style: {width: "200px"}
});
ui.root.add(switchPanel);
有问题,我来改改 (opens new window)
上次更新: 2022/05/25, 03:27:07