Tabs
组件类型:UxTabsComponentPublicInstance
支持点、下划线、微笑类型,下划线支持左右滚动、左右推压效果
平台兼容性
UniApp X
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
√ | √ | √ | x | √ |
UniApp Vue Nvue
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
x | x | √ | x | x |
Props
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
left | Slot | 左插槽 | |
right | Slot | 右插槽 | |
theme | String | info | 按钮类型 |
modelValue | Number | 0 | 双向绑定值 |
datas | UxTab[] | tabs列表 | |
type | String | line | 类型 |
anim | String | scroll | 动效类型 |
anchorId | String | 锚点ScrollId | |
anchor | Boolean | false | 自动滚动到锚点 |
width | Any | auto | 宽度 |
height | Any | 44 | 高度 |
corner | Any | 0 | 圆角 |
selectedColor | String | $ux.Conf.fontColor | 选中颜色 |
unselectedColor | String | $ux.Conf.fontColor | 未选中颜色 |
background | String | $ux.Conf.backgroundColor | 背景色 |
backgroundDark | String | 深色none-不显示,auto-自动适配深色模式,其他-颜色 | |
lineColor | String | 线颜色selectedColor优先级更高 | |
lineWidth | Any | 20 | 线宽度0则自动适配 |
lineHeight | Any | 2 | 线高度、点直径 |
fontSize | Any | $ux.Conf.fontSize | 字体大小 |
selectSize | Any | $ux.Conf.fontSize | 选中字体大小 |
bold | Boolean | false | 字体加粗 |
selectBold | Boolean | false | 选中字体加粗 |
padding | Any | 12 | 内部padding |
duration | Number | 300 | 过渡时间 |
offset | Any | 0 | 锚点偏移距离 |
theme
值 | 说明 |
---|---|
text | 文字 |
info | 默认 |
primary | 主要 |
success | 成功 |
warning | 警告 |
error | 错误 |
type
值 | 说明 |
---|---|
none无 | |
line下划线 | |
point点 | |
smile微笑 |
anim
值 | 说明 |
---|---|
none无 | |
scroll左右滚动 | |
push左右推压 |
backgroundDark
值 | 说明 |
---|---|
none不显示 | |
auto自动适配深色模式 | |
color其他颜色 |
Events
事件名 | 说明 | 参数 |
---|---|---|
change | 当前选择下标改变时触发 | |
anchor | 当要滚动目标时触发 |
示例代码
html
<template>
<ux-page :stack="showDoc">
<ux-navbar :title="title" :border="false">
<template v-slot:right>
<!-- #ifndef MP -->
<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
<!-- #endif -->
</template>
</ux-navbar>
<ux-scroll>
<ux-card direction="column" icon="flag-filled" title="选项卡导航栏" :bold="true">
<ux-text text="支持点、下划线、微笑类型,下划线支持左右滚动、左右推压效果"></ux-text>
</ux-card>
<ux-card direction="column" icon="arrowright" title="左右滚动" :bold="true">
<ux-tabs v-model="tabIndex" :datas="tabs"></ux-tabs>
</ux-card>
<ux-card direction="column" icon="arrowright" title="左右推压" :bold="true">
<ux-tabs anim="push" theme="success" :select-size="15" :line-width="0" v-model="tabIndex" :datas="tabs"></ux-tabs>
</ux-card>
<ux-card direction="column" icon="arrowright" title="微笑" :bold="true">
<ux-tabs type="smile" :select-bold="true" selected-color="red" v-model="tabIndex" :datas="tabs"></ux-tabs>
</ux-card>
<ux-card direction="column" icon="arrowright" title="点" :bold="true">
<ux-tabs type="point" theme="warning" v-model="tabIndex" :datas="tabs"></ux-tabs>
</ux-card>
<ux-card direction="column" icon="arrowright" title="左右插槽" :bold="true">
<ux-tabs v-model="tabIndex" :datas="tabs">
<template #left>
<ux-button theme="primary" :ml="10" text="菜单1"></ux-button>
</template>
<template #right>
<ux-button theme="warning" :mr="10" text="菜单2"></ux-button>
</template>
</ux-tabs>
</ux-card>
<ux-card direction="column" icon="arrowright" title="自定义宽度、颜色、圆角" :bold="true">
<ux-tabs :width="200" :height="38" :corner="22" background="#00a900" v-model="tabIndex" :datas="tabs"></ux-tabs>
</ux-card>
<ux-placeholder :height="200">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
</ux-row>
</ux-placeholder>
</ux-scroll>
</ux-page>
</template>
<template>
<ux-page :stack="showDoc">
<ux-navbar :title="title" :border="false">
<template v-slot:right>
<!-- #ifndef MP -->
<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
<!-- #endif -->
</template>
</ux-navbar>
<ux-scroll>
<ux-card direction="column" icon="flag-filled" title="选项卡导航栏" :bold="true">
<ux-text text="支持点、下划线、微笑类型,下划线支持左右滚动、左右推压效果"></ux-text>
</ux-card>
<ux-card direction="column" icon="arrowright" title="左右滚动" :bold="true">
<ux-tabs v-model="tabIndex" :datas="tabs"></ux-tabs>
</ux-card>
<ux-card direction="column" icon="arrowright" title="左右推压" :bold="true">
<ux-tabs anim="push" theme="success" :select-size="15" :line-width="0" v-model="tabIndex" :datas="tabs"></ux-tabs>
</ux-card>
<ux-card direction="column" icon="arrowright" title="微笑" :bold="true">
<ux-tabs type="smile" :select-bold="true" selected-color="red" v-model="tabIndex" :datas="tabs"></ux-tabs>
</ux-card>
<ux-card direction="column" icon="arrowright" title="点" :bold="true">
<ux-tabs type="point" theme="warning" v-model="tabIndex" :datas="tabs"></ux-tabs>
</ux-card>
<ux-card direction="column" icon="arrowright" title="左右插槽" :bold="true">
<ux-tabs v-model="tabIndex" :datas="tabs">
<template #left>
<ux-button theme="primary" :ml="10" text="菜单1"></ux-button>
</template>
<template #right>
<ux-button theme="warning" :mr="10" text="菜单2"></ux-button>
</template>
</ux-tabs>
</ux-card>
<ux-card direction="column" icon="arrowright" title="自定义宽度、颜色、圆角" :bold="true">
<ux-tabs :width="200" :height="38" :corner="22" background="#00a900" v-model="tabIndex" :datas="tabs"></ux-tabs>
</ux-card>
<ux-placeholder :height="200">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
</ux-row>
</ux-placeholder>
</ux-scroll>
</ux-page>
</template>
ts
<script setup>
import * as plus from '@/uni_modules/ux-plus'
import { UxTab } from '@/uni_modules/ux-frame'
const title = ref('')
const tabs = [
{
name: 'Tab1',
},
{
name: 'Tab2 加长版',
badge: 10
},
{
name: 'Tab3',
},
{
name: 'Tab4',
badge: 10,
reddot: true
},
{
name: 'Tab5 加长版',
},
{
name: 'Tab6',
},
{
name: 'Tab7',
},
{
name: '被禁用',
disabled: true
}
] as UxTab[]
const tabIndex = ref(0)
const showDoc = ref(false)
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/tabs.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
</script>
<script setup>
import * as plus from '@/uni_modules/ux-plus'
import { UxTab } from '@/uni_modules/ux-frame'
const title = ref('')
const tabs = [
{
name: 'Tab1',
},
{
name: 'Tab2 加长版',
badge: 10
},
{
name: 'Tab3',
},
{
name: 'Tab4',
badge: 10,
reddot: true
},
{
name: 'Tab5 加长版',
},
{
name: 'Tab6',
},
{
name: 'Tab7',
},
{
name: '被禁用',
disabled: true
}
] as UxTab[]
const tabIndex = ref(0)
const showDoc = ref(false)
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/tabs.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
</script>
css
<style lang="scss">
</style>
<style lang="scss">
</style>