一个文字竖向滚动的vue方案,使用swiper配置

先导入swiper,npm i swiper@8
安个8版本的,配置在swiper官网可查

<template>
    <div class="swiper anjian_swiper">
        <div class="swiper-wrapper">
            <div
                v-for="(item, index) in scrollData"
                :key="index"
                class="swiper-slide"
            >
                <span>{{ item.name }}</span>
                <span>{{ item.caseType }}</span>
                <span>{{ item.disputeType }}</span>
                <span>{{ item.createDate }}</span>
            </div>
        </div>
    </div>
</template>
<script>
//下面文件地址用官网的会出问题,自己找的全局导入的地址
import Swiper from "swiper/swiper-bundle.js";
import "swiper/swiper-bundle.css";
export default {
    data() {
        return {
            scrollData: [],
            swiper: {},
        };
    },
    watch: {
        scrollData(val) {
            this.$nextTick(() => {
                this.swiper.init();
            });
        },
    },
    mounted() {
        this.swiper = new Swiper(".swiper", {
            direction: "vertical",
            loop: true,
            speed: 2000,
            slidesPerView: "auto",
            autoplay: {
                delay: 0,
                loopPreventsSlide: true,
                disableOnInteraction: false,
                pauseOnMouseEnter: true,
            },
            paginationClickable: true,
            init: false,
        });
    },
    methods: {
        getData(data) {
            this.scrollData = data;
        },
    },
};
</script>

<style scoped>
.anjian_swiper {
    height: calc(100% - 0.9rem);
    overflow: hidden;
    font-size: 0;
}
.anjian_swiper .swiper-wrapper {
    transition-timing-function: linear !important;
}
.anjian_swiper .swiper-slide {
    text-align: left;
    height: 0.4rem;
    line-height: 0.4rem;
}
.anjian_swiper .swiper-slide span {
    display: inline-block;
    font-size: 0.18rem;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
}
.anjian_swiper .swiper-slide span:nth-child(1) {
    width: 15%;
}
.anjian_swiper .swiper-slide span:nth-child(2) {
    width: 25%;
}
.anjian_swiper .swiper-slide span:nth-child(3) {
    width: 25%;
}
.anjian_swiper .swiper-slide span:nth-child(4) {
    width: 35%;
}
.wraptit {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0 0 10px 0;
    margin-bottom: 10px;
}

.wraptit span {
    display: inline-block;
    font-size: 0.18rem;
    color: rgba(255, 255, 255, 0.6);
}
</style>
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容