上下 方向滚动
<template>
<div class="scroll-wrap">
<div class="scroll-content">
<vue3-seamless-scroll class="scroll-list" :list="list" :hover="true" :step="0.4" :wheel="true" :isWatch="true">
<ul class="scroll-ul" v-for="(item, index) in list" :key="index">
<li class="scroll-li">
<span style="min-width: 80px; width: calc(100% - 180px)">{{ item.title }}</span>
</li>
</ul>
</vue3-seamless-scroll>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { Vue3SeamlessScroll } from "vue3-seamless-scroll";
const list = ref([
{
title: "Vue3.0 无缝滚动组件展示数据第1条",
date: Date.now(),
},
{
title: "Vue3.0 无缝滚动组件展示数据第2条",
date: Date.now(),
},
{
title: "Vue3.0 无缝滚动组件展示数据第3条",
date: Date.now(),
},
{
title: "Vue3.0 无缝滚动组件展示数据第4条",
date: Date.now(),
},
{
title: "Vue3.0 无缝滚动组件展示数据第5条",
date: Date.now(),
},
{
title: "Vue3.0 无缝滚动组件展示数据第6条",
date: Date.now(),
},
{
title: "Vue3.0 无缝滚动组件展示数据第7条",
date: Date.now(),
},
{
title: "Vue3.0 无缝滚动组件展示数据第8条",
date: Date.now(),
},
{
title: "Vue3.0 无缝滚动组件展示数据第9条",
date: Date.now(),
},
]);
</script>
<style scoped>
.scroll-wrap {
width: 500px;
height: 350px;
overflow: hidden;
}
.scroll-header,
.scroll-content {
width: 100%;
display: flex;
}
.scroll-list {
width: 100%;
overflow: hidden;
}
.scroll-ul {
width: 100%;
display: flex;
flex-direction: column;
}
.scroll-li {
width: 100%;
display: flex;
line-height: 35px;
}
.scroll-li>span {
display: flex;
height: 35px;
line-height: 35px;
border-top: 1px solid #dcdfe6;
border-left: 1px solid #dcdfe6;
padding-left: 5px;
overflow: hidden;
}
.scroll-li>span:last-child {
border-right: 1px solid #dcdfe6;
}
.scroll-header .scroll-li {
background-color: #F8F9FF;
}
.scroll-header .scroll-li>span {
font-weight: bold;
border-top: none;
}
.scroll-content .scroll-ul:last-child .scroll-li {
border-bottom: 1px solid #dcdfe6;
}
</style>
左右方向滚动
<template>
<div class="scroll-wrap">
<div class="scroll-content">
<vue3-seamless-scroll class="scroll-list" :list="list" direction="left" :hover="true" :step="0.4" :wheel="true"
:isWatch="true">
<div class="scroll-container">
<div class="scroll-item" v-for="(item, index) in list" :key="index">
<span>{{ item.title }}</span>
</div>
</div>
</vue3-seamless-scroll>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { Vue3SeamlessScroll } from "vue3-seamless-scroll";
const list = ref([
{
title: "无缝滚动组件数据1",
date: Date.now(),
},
{
title: "无缝滚动组件数据2",
date: Date.now(),
},
{
title: "无缝滚动组件数据3",
date: Date.now(),
},
{
title: "无缝滚动组件数据4",
date: Date.now(),
},
{
title: "无缝滚动组件数据5",
date: Date.now(),
},
{
title: "无缝滚动组件数据6",
date: Date.now(),
},
{
title: "无缝滚动组件数据7",
date: Date.now(),
},
{
title: "无缝滚动组件数据8",
date: Date.now(),
},
]);
</script>
<style scoped>
.scroll-wrap {
width: 500px;
height: 350px;
overflow: hidden;
}
.scroll-content {
width: 100%;
height: 100%;
overflow: hidden;
}
.scroll-list {
width: 100%;
height: 100%;
overflow: hidden;
}
.scroll-container {
display: flex;
flex-direction: row;
/* 确保子元素水平排列 */
white-space: nowrap;
/* 防止文本换行 */
}
.scroll-item {
display: inline-block;
/* 确保每个项目水平排列 */
margin-right: 20px;
/* 调整项目之间的间距 */
line-height: 35px;
white-space: nowrap;
}
.scroll-item span {
display: inline-block;
height: 35px;
line-height: 35px;
padding-left: 5px;
overflow: hidden;
}
</style>