vue-awesome-swiper实现文字滚动

本文档介绍了如何在Vue项目中通过vue-awesome-swiper组件来实现文字滚动的效果,包括如何全局引入组件、具体使用方法及样式设置等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.1 引入

全局引入,其他地方不需再引入。

import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'

Vue.use(VueAwesomeSwiper)
1.2 使用
<div class="list">
    <swiper :options="swiperOptions" class="swiper-no-swiping">
        <swiper-slide v-for="(item, index) in awardAllList" :key="item.id" class="item">
            恭喜 {{item.mobile}} &nbsp;抽中&nbsp; {{item.content}}
        </swiper-slide>
    </swiper>
</div>



data () {
      return {    
        swiperOptions: {
          autoplay: {
            delay: 1000
          },
          direction: 'vertical',
          slidesPerView: 5,
          loop: true,
          observer: true,
          observeParents: true,
          speed: 1000,
          mousewheel: false,
          noSwiping: true
        }
      }
    },


或者在计算属性里面设置swiperOptions

computed: {
   swiperOptions () {
     return {
       autoplay: {
         delay: 1000
       },
       direction: 'vertical',
       slidesPerView: 5,
       loop: true,
       observer: true,
       observeParents: true,
       speed: 1000,
       mousewheel: false,
       noSwiping: true
     }
   }
 },
1.3 样式
.list {
     width:  rem(588);
     height: rem(260);
     margin: rem(240) auto 0;
     overflow: hidden;
     .swiper-container {
         height: 100% !important;
         .item{
             height: rem(40) !important;
             line-height: rem(40);
             color: #f5f5f5;
             font-size: rem(28);
             margin-bottom: rem(12);
             letter-spacing: 1px;
         }
     }
 }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值