web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

vuejs实现多条文字无缝上下滚动

297 ℃
     
1、template代码
<div class="marquee-wrap">
    <ul class="marquee-list" :class="{ 'animate-up': animateUp }">
      <li v-for="(item, index) in listData" :key="index">{{ item }}</li>
    </ul>
</div>

2、script代码
export default {
  name: "marquee-up",
  data() {
    return {
      animateUp: false,
      listData: [
        "李白1",
        "白居易2",
        "杜甫3",
        "王安石4",
        "孟浩然5",
        "李清照6",
        "苏轼7",
        "琵琶行8",
        "李老头9"
      ],
      timer: null
    };
  },
  mounted() {
    this.timer = setInterval(this.scrollAnimate, 2000);
  },
  methods: {
    scrollAnimate() {
      this.animateUp = true;
      setTimeout(() => {
        for (let i = 0; i < 3; i++) {
          this.listData.push(this.listData[i]);
        }
        // this.listData.shift();
        this.listData.splice(0, 3);
        this.animateUp = false;
      }, 1000);
    }
  },
  destroyed() {
    clearInterval(this.timer);
  }
}

3、style样式
.marquee-wrap {
  height: 180px;
  margin: 0 auto;
  overflow: hidden;
  .marquee-list {
    li {
      width: 100%;
      height: 100%;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
      padding: 0 20px;
      list-style: none;
      line-height: 30px;
      text-align: center;
      color: #fff;
      font-size: 18px;
      font-weight: 400;
    }
  }
  .animate-up {
    transition: all 0.5s ease-in-out;
    transform: translateY(-90px);
  }
}

一款免费开源效果酷炫​的 Vue / React 大屏数据展示组件库——DataV 

vue项目动态设置background背景色,解决颜色被替换问题

vue2项目使用预渲染prerender-spa-plugin插件解决seo优化

vue安装axios脚手架报“ ./node_modules/axios/lib/core/mergeConfig.js”错误解决方法

Lunar组件获取指定月份的所有老黄历每日宜忌

上面是“vuejs实现多条文字无缝上下滚动”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_23.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 网站首页 > vuejs
本文共计1138个字,预计阅读时长8分钟
生活小工具,收录了80多款小工具
上一篇: 推荐一个可以查询老黄历的网站,可以根据五行取名!
下一篇: 详细介绍HTTP状态码不同之处的原因(什么原因导致的)
x 打工人ai神器