Tabbar (底部导航)
页面切换底部菜单
支持平台
安卓 | ios | 鸿蒙 | web | 微信小程序 |
---|---|---|---|---|
√ | √ | √ | √ | √ |
示例代码
html
<template>
<t-page main-class="p-30">
<t-card main-class="tdr tdb mb-30" title='Tabbar 底部导航' sub-title="页面切换底部菜单"></t-card>
<t-section title='使用图片' main-class="tdr tdb mb-30"></t-section>
<t-tabbar main-class="tdr tdb mb-30" @change="onchange">
<template v-slot:default="{current,type}">
<t-row>
<t-tabbar-item v-for="(item,index) in tabList2" :key="index">
<t-icon :name="current.toString()==index.toString()?item.activeIcon:item.inactiveIcon"
main-class="s-45"></t-icon>
<t-text :type="current.toString()==index.toString()?type:'info'" :text="item.label"
main-class="mt-5"></t-text>
</t-tabbar-item>
</t-row>
</template>
</t-tabbar>
<t-section title='使用图标+切换主题' main-class="tdr tdb mb-30">
</t-section>
<t-tabbar type='e' main-class="df dlrb-0 bt-1px,s,#ccc ov" @change="onchange">
<template v-slot:default="{current,type}">
<t-row main-class="ov">
<t-tabbar-item v-for="(item,index) in tabList" :key="index">
<t-col main-class="fc dr ov">
<t-icon :type="current.toString()==index.toString()?type:'info'"
:name="current.toString()==index.toString()?item.activeIcon:item.inactiveIcon"
main-class="s-45"></t-icon>
<t-text :type="current.toString()==index.toString()?type:'info'" :text="item.label"
main-class="mt-5"></t-text>
<t-badge v-if="item.badgeValue>0" type="error" main-class="da dl-50 dt-n5"
:text="`${item.badgeValue}`"></t-badge>
</t-col>
</t-tabbar-item>
</t-row>
</template>
</t-tabbar>
</t-page>
</template>
<script>
type tabbarOptions = {
activeIcon : string
inactiveIcon : string
raised : boolean
label : string
badgeValue : number
}
export default {
data() {
return {
iconsrc: "email-fill",
current: 0,
tabList2: [{
activeIcon: '/static/tabbar/ui1.png',
inactiveIcon: '/static/tabbar/ui.png',
raised: false,
label: 'UI',
badgeValue: 0
},
{
activeIcon: '/static/tabbar/table1.png',
inactiveIcon: '/static/tabbar/table.png',
raised: false,
label: '图表',
badgeValue: 9999
},
{
activeIcon: '/static/tabbar/api1.png',
inactiveIcon: '/static/tabbar/api.png',
raised: true,
label: '插件',
badgeValue: 1
},
{
activeIcon: '/static/tabbar/template1.png',
inactiveIcon: '/static/tabbar/template.png',
raised: false,
label: '模版',
badgeValue: 0
},
{
activeIcon: '/static/tabbar/my1.png',
inactiveIcon: '/static/tabbar/my.png',
raised: false,
label: '我的',
badgeValue: 0
}] as tabbarOptions[],
tabList1: [{
activeIcon: '/static/tabbar/home_s.png',
inactiveIcon: '/static/tabbar/home.png',
raised: false,
label: '首页',
badgeValue: 0
},
{
activeIcon: '/static/tabbar/find_s.png',
inactiveIcon: '/static/tabbar/find.png',
raised: false,
label: '发现',
badgeValue: 9999
},
{
activeIcon: 'home-fill',
inactiveIcon: 'home',
raised: false,
label: '购物车',
badgeValue: 1
},
{
activeIcon: '/static/tabbar/msg_s.png',
inactiveIcon: '/static/tabbar/msg.png',
raised: false,
label: '消息',
badgeValue: 0
},
{
activeIcon: '/static/tabbar/me_s.png',
inactiveIcon: '/static/tabbar/me.png',
raised: false,
label: '我的',
badgeValue: 0
}] as tabbarOptions[],
tabList: [{
activeIcon: 'home-fill',
inactiveIcon: 'home',
raised: false,
label: '首页',
badgeValue: 0
},
{
activeIcon: 'play-circle-fill',
inactiveIcon: 'play-circle',
raised: false,
label: '发现',
badgeValue: 9999
},
{
activeIcon: 'bag-fill',
inactiveIcon: 'bag',
raised: false,
label: '购物车',
badgeValue: 1
},
{
activeIcon: 'email-fill',
inactiveIcon: 'email',
raised: false,
label: '消息',
badgeValue: 0
},
{
activeIcon: 'rmb-circle-fill',
inactiveIcon: 'rmb-circle',
raised: false,
label: '我的',
badgeValue: 0
}] as tabbarOptions[]
};
},
methods: {
onchange(e : number) {
console.log(e)
},
tabBarClick(index : number) {
this.current = index
}
}
}
</script>
属性
名称 | 类型 | 默认值 | 说明 | 可选值 |
---|---|---|---|---|
size | String | mini | 组件尺寸 | large(大尺寸), medium(中尺寸), small(小尺寸), mini(迷你) |
type | String | "" | 组件类型 | info(信息), primary(正常), error(错误), warning(警告), success(成功) |
disabled | Boolean | false | 组件是否禁用 | false, true |
stop | Boolean | false | 是否阻止事件冒泡(Tui统一写法处理事件冒泡) | false, true |
hover | Boolean | true | 是否有点击效果 | false, true |
path | String | "" | 点击组件后跳转的页面路径,如果为空则响应点击事件,如果不为空则跳转页面不会响应单击事件。 | - |
mainClass | String | "" | 组件根节点的样式 | - |
nativeClass | String | "" | 组件根节点原生样式 | - |
effect | String | "normal" | 组件显示主题 | normal(正常), dark(深色), light(浅色), plain(镂空) |
current | Number | 1 | 当前页索引 | |
type | String | p |
事件
名称 | 返回参数 | 说明 |
---|---|---|
change | - | - |
插槽
名称 | 返回值 | 说明 |
---|---|---|
default | - |