切换卡 Tabs
Constructor
Implements: Widget
Tutorials: 控件对象使用快速入门
可设置的属性
Name | Type | Description |
---|---|---|
name | String | 控件的名字,唯一标志 |
title | String | 控件title |
hidden | Boolean | 隐藏 |
tabs | Array | 选项卡内容 |
selectedIndex | Number | 选中的选项卡索引 |
可获取的属性
Name | Type | Description |
---|---|---|
name | String | 控件的名字,唯一标志 |
title | String | 控件title |
hidden | Boolean | 隐藏 |
selectedIndex | Number | 选中的选项卡索引 |
方法
hide
Description: 隐藏一个tab页
Name | Description |
---|---|
调用参数 | Nameindex Type Number Description 面板索引 |
返回值 | 无 |
调用举例:
var widget = vjsp.Parser.getWidgetByName('tabs');
widget.doMethod('hide' , 1);
show
Description: 显示一个tab页
Name | Description |
---|---|
调用参数 | Nameindex Type Number Description 面板索引 |
返回值 | 无 |
调用举例:
var widget = vjsp.Parser.getWidgetByName('tabs');
widget.doMethod('show' , 1);
addTab
Description: 增加一个tab页
调用参数:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
text | String | tab标签文字 | ||
content | String|HTMLElement | 内容html(或HTML元素) | ||
content | Boolean | 内容html(或HTML元素) | ||
hidden | String | <optional> | false | 是否隐藏 |
返回值: 无
调用举例:
var widget = vjsp.Parser.getWidgetByName('tabs');
widget.doMethod('addTab' , '新增Tab' , '新增content');
removeTab
Description: 删除一个tab页
Name | Description |
---|---|
调用参数 | Nameindex Type Number Description 面板索引 |
返回值 | 无 |
调用举例:
var widget = vjsp.Parser.getWidgetByName('tabs');
widget.doMethod('removeTab' , 1);
事件
selected
Description: 选项卡被选择
Name | Description |
---|---|
回调函数参数 | NameselectedIndex Type Object Description 被选择的选项卡索引 |
绑定举例:
var widget = vjsp.Parser.getWidgetByName('tabs');
widget.on('selected' , function(selectedIndex){
vjsp.alert('切换到tab索引:' + selectedIndex);
});
removeTab
Description: 删除事件 可通过this.reurnValue=false
取消删除
Name | Type | Description |
---|---|---|
回调函数参数 | NameremoveTabIndex Type Object Description 被删除的选项卡索引 | |
returnValue | Boolean | this.reurnValue=false 取消删除 |
绑定举例:
var widget = vjsp.Parser.getWidgetByName('tabs');
widget.on('removeTab' , function(removeTabIndex){
//禁止删除索引为0的 tab
if(removeTabIndex === 0){
this.returnValue = false;
}
});
hidden
Description: 隐藏事件(隐藏显示触发 回调参数为隐藏状态)
回调函数参数
Name | Type | Description |
---|---|---|
hiddenState | Boolean | 隐藏状态true 为隐藏、false 为取消隐藏 |
绑定举例:
var widget = vjsp.Parser.getWidgetByName('tabs');
widget.on('hidden' , function(hiddenState){
if(hiddenState){
vjsp.alert('控件被隐藏');
}else{
vjsp.alert('控件取消隐藏');
}
});