zoukankan      html  css  js  c++  java
  • vue 新闻列表滚动效果

    <template>
      <div class="scroll-wrap">
        <div class="scroll-content" :style="{ top }" @mouseenter="Stop()" @mouseleave="Up()">
          <p v-for="item in prizeList">
            <a :href="item.src">{{item.name}}</a>
          </p>
        </div>
      </div>
    </template>
    
    <script>
    export default {
      name: 'complexTable',
      data () {
        return {
          prizeList: [
            { name: '城轨采购网', src: 'http://www.railunique.com' },
            { name: '天津地铁电子采购平台', src: 'http://www.railunique.com' },
            { name: '南昌地铁', src: 'http://www.railunique.com' },
            { name: '南昌地铁', src: 'http://www.railunique.com' },
            { name: '兰州地铁招标信息', src: 'http://www.railunique.com' },
            { name: '西安公共资源交易中心', src: 'http://www.railunique.com' }
          ],
          activeIndex: 0,
          intnum: undefined
        }
      },
      computed: {
        top () {
          return -this.activeIndex * 50 + 'px'
        }
      },
      created () {
        this.ScrollUp()
      },
      methods: {
        ScrollUp () {
          this.intnum = setInterval(_ => {
            if (this.activeIndex < this.prizeList.length) {
              this.activeIndex += 1
            } else {
              this.activeIndex = 0
            }
          }, 1000)
        },
        Stop () {
          clearInterval(this.intnum)
        },
        Up () {
          this.ScrollUp()
        }
      }
    }
    </script>
    <style>
      .scroll-wrap {
        height: 150px;
        overflow: hidden;
      }
      .scroll-content {
        position: relative;
        transition: top 0.5s;
      }
      .scroll-content p {
        line-height: 50px;
        text-align: center;
      }
    </style>
    
  • 相关阅读:
    题解 AT5228 【[ABC162A] Lucky 7】
    题解 P6467 【[COCI2008-2009#6] BUKA】
    2020 Codeforces 愚人节比赛题解 A~D
    题解 AT4251 【[ABC110A] Maximize the Formula】
    题解 AT5638 【November 30】
    题解 AT4164 【[ABC102A] Multiple of 2 and N】
    多项式全家桶
    烂题推荐
    NOIP 2020 游记
    P5048 题解
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13300620.html
Copyright © 2011-2022 走看看