更新记录
1.0.4(2025-07-05) 下载此版本
优化组件
1.0.3(2025-06-26) 下载此版本
更新使用示例
1.0.2(2025-06-26) 下载此版本
优化说明文挡
查看更多平台兼容性
uni-app
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | - | - | - | - | - | - | - |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
√ | √ | √ | - | √ | - | - | √ | - | - | - |
hbxw-timeaxis 时间轴式列表展示组件
介绍
高度可配置,内容可定义的时间轴式列表展示组件
使用示例
推荐先直接复制示例代码到工程中看效果了解下使用方法再投入项目使用。
<template>
<view class="test-timeline">
<view class="hbxw-timeaxis-title">基础使用示例</view>
<view class="hbxw-timeaxis-container">
<hbxw-timeaxis>
<hbxw-timeaxis-item
:isFirst="index === 0"
:isLast="index === list.length - 1"
v-for="(item, index) in list"
:item="item"
:key="index"
></hbxw-timeaxis-item>
</hbxw-timeaxis>
</view>
<view class="hbxw-timeaxis-title">通过配置修改样式</view>
<view class="hbxw-timeaxis-container">
<hbxw-timeaxis>
<hbxw-timeaxis-item
:isFirst="index === 0"
:isLast="index === list.length - 1"
v-for="(item, index) in list"
:item="item"
:key="index"
point-bd-color="yellow"
point-color="blue"
point-width="20rpx"
line-style="solid"
line-color="grey"
title-color="red"
right-color="grey"
:sub-title-style="{color: 'green', fontSize: '28rpx'}"
:title-ellipsis="false"
>
</hbxw-timeaxis-item>
</hbxw-timeaxis>
</view>
<view class="hbxw-timeaxis-title">通过slot自定义内容</view>
<view class="hbxw-timeaxis-container">
<hbxw-timeaxis>
<hbxw-timeaxis-item
:isFirst="index === 0"
:isLast="index === list.length - 1"
v-for="(item, index) in list"
:item="item"
:key="index"
>
<template #point="{item}">
<view class="custom-point">{{index + 1}}</view>
</template>
<template #title="{item}">
<view>title:{{item.title}}</view>
</template>
<template #right="{item}">
<view>right:{{item.date}}</view>
</template>
<template #other="{item}">
<view>subTitle:{{item.subTitle}}</view>
</template>
</hbxw-timeaxis-item>
</hbxw-timeaxis>
</view>
</view>
</template>
<script>
export default {
data() {
return {
list: [
{
title: '从前从前有个人爱你很久,但偏偏风渐渐把距离吹得好远,好不容易又能再多爱一天,但故事的最后你好像还是说了拜拜',
date: '2024-12-10 18:14',
subTitle: '1234567890'
},{
title: '一起飞向天',
date: '2024-12-10 18:14',
subTitle: '9874563210'
},{
title: '从前从前有个人爱你很久,但偏偏风渐渐把距离吹得好远,好不容易又能再多爱一天,但故事的最后你好像还是说了拜拜加油努力冲冲冲',
date: '2024-12-10 18:14',
subTitle: '9874563210'
}
]
}
},
methods: {
}
}
</script>
<style scoped>
.test-timeline{
width: 100%;
}
.hbxw-timeaxis-title{
font-size: 28rpx;
font-weight: bold;
margin-bottom: 10px;
}
.hbxw-timeaxis-container{
width: 680rpx;
margin:20rpx auto;
}
.custom-point{
width: 32rpx;
height: 32rpx;
background-color: #ff6b6b;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 20rpx;
margin-right: 10rpx;
}
</style>
API
Props
属性名 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
item | Object | null | 是 | 当前时间轴列表单项内容配置,结构见示例 |
pointWidth | String | 16rpx | 否 | 时间轴圆点宽度大小 |
pointColor | String | #AAF24E | 否 | 时间轴圆点背景色 |
pointBdColor | String | #000 | 否 | 时间轴圆点边框颜色 |
titleColor | String | #488100 | 否 | 时间轴列表标题文本颜色 |
rightColor | String | #767676 | 否 | 时间轴列表右侧内容文本颜色 |
subTitleStyle | Object | null | 否 | 时间轴标题下侧内容样式配置对象 |
rightStyle | Object | null | 否 | 时间轴标题右侧内容样式配置对象 |
lineStyle | String | dash | 否 | 时间轴列表贯穿线款式,dash:虚线 solid:实线 |
lineColor | String | #000 | 否 | 时间轴列表贯穿线条颜色 |
titleEllipsis | Boolean | true | 否 | 时间轴列表标题是否是单行省略 |
gap | String | 48rpx | 否 | 时间轴项目之间的间距 |
Slots
插槽名称 | 参数 | 说明 |
---|---|---|
point | {item} | 自定义时间轴圆点 |
title | {item} | 自定义时间轴标题 |
right | {item} | 自定义时间轴右侧 |
other | {item} | 自定义时间轴标题下方内容 |
注意事项
- 我在使用过程中发现在支付宝小程序端如果你用了一个插槽,默认的插槽内容不会展示了,那就所有内容都要通过插槽来实现了
- 如果使用了自定义插槽point,那就要传pointWidth和subTitleStyle用于调整布局,详情查看上面的 slot示例