时间周 xWeekbar
在线预览
在线模拟尺寸:
介绍
样式丰富,非常精美,能够适应不同设计要求.
平台兼容
| Harmony | H5 | andriod | IOS | 小程序 | UTS | UNIAPP-X SDK | version |
|---|---|---|---|---|---|---|---|
| ☑ | ☑ | ☑️ | ☑️ | ☑️ | ☑️ | 4.76+ | 1.1.18 |
文件路径
ts
@/uni_modules/tmx-ui/components/x-weekbar/x-weekbar.uvue使用
ts
<x-weekbar></x-weekbar>Props 属性
| 名称 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| modelValue | 同步受控当前选中日期,空时不会自动选中。 | string | "" |
| startDate | 开始的日期 | string | "1900-1-1" |
| endDate | 结束的日期 | string | "2100-1-1" |
| format | 格式展示在组件上的日期. | string | "DD" |
| cn | 周上面显示的中文名称.'一', '二', '三', '四', '五', '六', '日'由于有属性seekDay的原因这里的顺序你不允许自己排列,你只能按照0-6的顺序来排列。即周一至周日,内部会自动再排列以满足seekDay的值。 | string[] | () : string[] => [] as string[] |
| seekDay | 你当前的一周的第一天的索引值是几:0: 周一,1: 周二,2: 周三,3: 周四,4: 周五,5: 周六,6: 周日 | number | 0 |
| color | 背景 | string | "white" |
| darkColor | 暗黑时的背景,如果不提供使用sheet暗黑背景 | string | "" |
| fontColor | 字号颜色 | string | "#333333" |
| fontSize | 字号颜色 | string | "14" |
| fontDarkColor | 暗黑时的字号颜色 | string | "#fbfbfb" |
| fontActiveColor | 激活时的字号颜色,不区分暗黑 | string | "white" |
| mode | 选中的样式.rect和circular,none三种 | string | "rect" |
| rectRound | mode为rect时的选中背景圆角 | string | "5" |
| round | 组件圆角 | string | "0" |
| activeBgColor | 激活时的背景,不区分暗黑,不填充默认是全局主题色 | string | "" |
| topHeight | 上部分标题的高 | string | "32" |
| bottomHeight | 下部分日期的高. | string | "42" |
| padding | 左右,上下的间隙 | string[] | () : string[] => ['4', '8'] as string[] |
| showAction | `` | boolean | true |
| actionIcon | `` | string | 'arrow-left-s-line' |
| actionSize | 操作栏的图标大小 | string | '24' |
| actionColor | 操作栏的图标颜色 | string | '#bebebe' |
| actionDarkColor | 操作栏的图标暗黑颜色 | string | '#bebebe' |
| emptyValueSelected | 当前modelValue为空时,这里设置为false时,默认进来不会选中当前日期. | boolean | true |
| dateStatus | 给日期设定状态类型为:xCalendarDateStyleStatusProps | xCalendarDateStyleStatusType[] | ():xCalendarDateStyleStatusType[] => [] as xCalendarDateStyleStatusType[] |
Events 事件
| 名称 | 参数 | 说明 |
|---|---|---|
| change | date: string | 时间选中时触发 |
| swiperChange | dates: string[] | 时间周切换时触发,比如滑动切换,切换周时触发 |
| update:modelValue | date: string | 等同v-model |
Slots 插槽
| 名称 | 说明 | 数据 |
|---|---|---|
| left | 左边操作栏按钮 | - |
| right | 右边操作栏按钮 | - |
Ref 方法
| 名称 | 参数 | 返回值 | 说明 |
|---|
示例文件路径
json
/pages/daohang/weekbar示例源码
uvue
vue
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<page-meta :page-style="`background-color:${xThemeConfigBgColor}`">
<navigation-bar :background-color="xThemeConfigNavBgColor" :front-color="xThemeConfigNavFontColor"></navigation-bar>
</page-meta>
<!-- #endif -->
<x-sheet :margin="['0']" :round="['0']">
<x-text font-size="18" class=" text-weight-b mb-8">时间周 xWeekbar</x-text>
<x-text color="#999999" >
样式丰富,非常精美,能够适应不同设计要求.
</x-text>
</x-sheet>
<x-weekbar :date-status="dateStatus" :start-date="startDate" :end-date="endDate" v-model="nowDate" :seekDay="6" ></x-weekbar>
<x-sheet :margin="['0','8','0','0']" :round="['0']">
<x-text font-size="18" class=" text-weight-b ">无操作栏及圆模式</x-text>
</x-sheet>
<x-weekbar :showAction="false" mode="circular" :padding="['0','4']"></x-weekbar>
<x-sheet :margin="['0','8','0','0']" :round="['0']">
<x-text font-size="18" class=" text-weight-b ">无背景模式</x-text>
</x-sheet>
<x-weekbar :showAction="false" color="transparent" fontActiveColor="primary" mode="none" :padding="['0','0']"></x-weekbar>
<x-sheet :margin="['0']" :round="['0']">
<x-text font-size="18" class=" text-weight-b ">个性化</x-text>
</x-sheet>
<x-weekbar :showAction="false"
color="#fff60a"
fontDarkColor="#000000"
darkColor="#fff60a" activeBgColor="#000000" mode="circular" :padding="['0','4']"></x-weekbar>
<x-sheet :margin="['0']" :round="['0']">
<x-text font-size="18" class=" text-weight-b ">个性化(默认不选中)</x-text>
</x-sheet>
<x-weekbar
actionIcon="arrow-left-circle-line"
rectRound="8"
color="error"
darkColor="error"
fontColor="rgba(255,255,255,0.7)"
fontDarkColor="rgba(255,255,255,0.8)"
activeBgColor="#6b0902"
mode="rect"
actionDarkColor="rgba(255,255,255,0.4)"
actionColor="rgba(255,255,255,0.5)"
bottomHeight="50"
topHeight="32"
:padding="['4','8']"
:emptyValueSelected="false"
>
</x-weekbar>
<view style="height: 50px;"></view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script setup>
import { xCalendarDateStyleStatusType } from "@/uni_modules/tmx-ui/interface.uts"
const nowDate = ref("2025-9-24")
const startDate = ref('2025-9-22')
const endDate = ref('2025-9-25')
const dateStatus = ref<xCalendarDateStyleStatusType[]>([{
between: {
start: "2025-9-25",
end: "2025-9-30",
color: "red",
notDate: ['2024-2-20'],
},
date: [
{ date: '2025-9-21', color: 'green' },
]
} as xCalendarDateStyleStatusType])
</script>
<style>
</style>