内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

Vue實(shí)現(xiàn)簡(jiǎn)易多行滾動(dòng)"彈幕"效果

看一下效果:

我們提供的服務(wù)有:成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、微信公眾號(hào)開(kāi)發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、武鳴ssl等。為1000+企事業(yè)單位解決了網(wǎng)站和推廣的問(wèn)題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的武鳴網(wǎng)站制作公司

Vue 實(shí)現(xiàn)簡(jiǎn)易多行滾動(dòng)"彈幕"效果 

實(shí)現(xiàn)任意行數(shù)的定時(shí)翻滾效果,不使用重復(fù)標(biāo)簽的方式,而是根據(jù)展示個(gè)數(shù)判斷是否缺省,并添加對(duì)應(yīng)展示個(gè)數(shù)的重復(fù)項(xiàng)來(lái)實(shí)現(xiàn)。

Vue 的演示代碼如下:

<template>
 <div class="demo-comment-container">
 <div
  class="scroll-container"
  :
 >
  <ul
  class="scroll-ul"
  :
  >
  <div
   v-for="(item, index) in list"
   :key="index"
   v-bind="baseStyle.style"
   :bgColor="baseStyle.style.bgColor__bg"
   :
   :class="['c-item-bg', 'c-item', !item.content && 'empty']"
  >
   <li
   class="c-item"
   >
   <div class="avatar">
    <img
    v-if="item.content"
    class="avatar-item"
    :src="item.photo"
    >
   </div>
   <div
    v-if="item.content"
    class="c-content"
    v-html="item.content"
   />
   </li>
  </div>
  </ul>
 </div>
 <div class="comment-entry">
  <div class="f">
  <div class="text-c">
   <span
   v-if="entry.type === 1"
   class="text"
   v-text="entry.text"
   />
   <div
   v-else
   class="img-container"
   >
   <img :src="entry.image">
   </div>
   <i
   v-if="count"
   class="c-c"
   >{{ count }}</i>
  </div>
  <div>
   <span class="fake-input">來(lái)發(fā)表你的看法吧~</span>
  </div>
  </div>
 </div>
 </div>
</template>
<script>
export default {
 inject: ['rgba'],
 props: {
 urlConfig: {
  type: Object,
  default: function () {
  return {}
  }
 },
 type: {
  type: String,
  default: 'hot'
 },
 pageSize: {
  type: Number,
  default: 50
 },
 open: {
  type: Boolean,
  default: true
 },
 entry: {
  type: Object,
  default: function () {
  return {
   type: 1, // 1 文字 2 自定義
   text: '',
   image: ''
  }
  }
 },
 number: {
  type: Number,
  default: 2
 },
 },
 data () {
 return {
  count: 2334,
  dom: null,
  height: 0, // 單項(xiàng)高度
  y: 0, // 每次移動(dòng)距離
  list: [], // 接口列表
  originLength: 0, // 原始數(shù)組長(zhǎng)度
  transition: 'ease all .4s',
  round: 0 // 需要滾動(dòng)多少輪
 }
 },
 created () {
 this.getCommentList()
 },
 mounted () {
 this.dom = document.querySelector('.c-item')
 // 計(jì)算可視區(qū)域高度
 this.height = 64 * this.number + (12 * (this.number - 1))
 },
 methods: {
 getCommentList () {
  // 接口數(shù)據(jù)
  const _list = []
  this.originLength = _list.length
  const mod = this.originLength % this.number
  let need = this.originLength < this.number ? (this.number - this.originLength) : mod > 0 ? this.number - mod : 0 // 計(jì)算出要添加的空白元素個(gè)數(shù)
  this.list = _list

  // set empty item
  const empty = JSON.parse(JSON.stringify(_list[0]))
  empty.content = ''

  // 補(bǔ)齊空白元素
  while (need) {
  this.list.push(empty)
  need--
  }

  // 填充重復(fù)元素
  let repeat = this.number
  let index = 0
  while (repeat) {
  this.list.push(_list[index])
  index++
  repeat--
  }

  this.round = this.list.length / this.number

  this.scroll()
 },
 scroll () {
  let count = 1
  setInterval(() => {
  count++
  this.y -= this.height + 12 // 移動(dòng)可視區(qū)域高度 + 最后一個(gè) item 的 margin-bottom
  this.transition = '.4s ease all'
  setTimeout(() => {
   if (count === this.round) {
   count = 1
   this.transition = ''
   this.y = 0
   }
  }, 800)
  }, 2000)
 }
 }
}
</script>

總結(jié)

以上所述是小編給大家介紹的Vue 實(shí)現(xiàn)簡(jiǎn)易多行滾動(dòng)"彈幕",希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)創(chuàng)新互聯(lián)網(wǎng)站的支持!
如果你覺(jué)得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!

分享題目:Vue實(shí)現(xiàn)簡(jiǎn)易多行滾動(dòng)"彈幕"效果
鏈接URL:http://www.rwnh.cn/article20/ghccco.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作小程序開(kāi)發(fā)、響應(yīng)式網(wǎng)站、企業(yè)建站、網(wǎng)站改版網(wǎng)站導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)
伊金霍洛旗| 文成县| 东乌珠穆沁旗| 信阳市| 汕头市| 陕西省| 电白县| 贵港市| 扎赉特旗| 沾化县| 大关县| 文成县| 祁门县| 海晏县| 金塔县| 屯门区| 普兰店市| 南江县| 邹城市| 托克托县| 新营市| 临澧县| 五河县| 梅河口市| 页游| 晋宁县| 长武县| 达拉特旗| 淮安市| 宁远县| 凭祥市| 嘉兴市| 神农架林区| 修水县| 蚌埠市| 乌拉特中旗| 龙门县| 永顺县| 扎兰屯市| 澜沧| 城市|