更新记录
1.0.0(2023-05-03) 下载此版本
完成
平台兼容性
uni-app
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
× | √ | √ | √ | √ | √ | - | - | - |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
√ | √ | √ | √ | √ | √ | - | √ | √ | √ | √ |
其他
多语言 | 暗黑模式 | 宽屏模式 |
---|---|---|
× | × | √ |
uni.scss(按项目实际颜色)
$uni-color-primary: #007aff;
$uni-color-success: #4cd964;
$uni-color-warning: #f0ad4e;
$uni-color-error: #dd524d;
$uni-color-info: #909399; //默认色
$uni-color-disabled: #c0c4cc; //禁止色
$uni-color-default: #dcdfe6;
依赖yll1024335892-ayi-icon组件
参数
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
modelValue / v-model | 选中的下标值或者列表项的 value 值 | string / number | ||
height | 高度 | number | 80 | |
list | 列表 | array | ||
loop | 是否循环显示 | boolean | true | |
fill | 选项卡是否填充 | boolean | false | |
gutter | 选项卡间隔 | number | 20 | |
border | 是否带有下边框 | boolean | true | |
color | 激活的字体及浮标颜色 | string | 主色 | |
un-color | 未激活的字体颜色 | string | ||
background-color | 背景色 | string | #fff | |
show-dropdown | 是否显示下拉框 | boolean | false |
方法
事件名称 | 说明 | 参数 |
---|---|---|
refresh | 特殊情况下,重新刷新布局 |
示例
基础用法
<template>
<ayi-tabs v-model="active" :list="list"></ayi-tabs>
</template>
<script lang="ts" setup>
import { ref } from "vue";
const active = ref<number>(0);
const list = ref<any[]>([
{
label: "数码"
},
{
label: "家电"
},
{
label: "母婴"
},
{
label: "潮牌"
}
]);
</script>
居中
配置 justify 参数
<template>
<ayi-tabs v-model="active" :list="list" justify="center"></ayi-tabs>
</template>
<script lang="ts" setup>
import { ref } from "vue";
const active = ref<number>(0);
const list = ref<any[]>([
{
label: "数码"
},
{
label: "家电"
},
{
label: "母婴"
},
{
label: "潮牌"
}
]);
</script>
填充
配置 fill 参数
<template>
<ayi-tabs v-model="active" :list="list" fill></ayi-tabs>
</template>
<script lang="ts" setup>
import { ref } from "vue";
const active = ref<number>(0);
const list = ref<any[]>([
{
label: "数码"
},
{
label: "家电"
},
{
label: "母婴"
},
{
label: "潮牌"
}
]);
</script>
自定义颜色
<template>
<ayi-tabs v-model="active" :list="list" color="red" un-color="blue" background-color="#f7f7f7"></ayi-tabs>
</template>
<script lang="ts" setup>
import { ref } from "vue";
const active = ref<number>(0);
const list = ref<any[]>([
{
label: "数码"
},
{
label: "家电"
},
{
label: "母婴"
},
{
label: "潮牌"
}
]);
</script>
下拉框
配置 show-dropdown 参数及添加 dropdown 插槽
<template>
<ayi-tabs v-model="active" :list="list" show-dropdown>
<template #dropdown>
<view class="dropdown">
<ayi-text
:value="item.label"
v-for="item in list"
:key="item.value"
:margin="10"
></ayi-text>
</view>
</template>
</ayi-tabs>
</template>
<script lang="ts" setup>
import { ref } from "vue";
const active = ref<number>(0);
const list = ref<any[]>([
{
label: "数码"
},
{
label: "家电"
},
{
label: "母婴"
},
{
label: "潮牌"
}
]);
</script>
<style lang="scss" scoped>
.dropdown {
background-color: #ddd;
padding: 20rpx;
}
</style>
更改绑定值
list 中不存在 value 的情况下,会以数组的下标返回。否则返回 value 值
<template>
<ayi-tabs v-model="active2" :list="list2"></ayi-tabs>
</template>
<script lang="ts" setup>
import { ref } from "vue";
const active2 = ref<string>("b");
const list2 = ref<any[]>([
{
label: "数码",
value: "a"
},
{
label: "家电",
value: "b"
},
{
label: "母婴",
value: "c"
},
{
label: "潮牌",
value: "d"
}
]);
</script>