日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > vue >内容正文

vue

Vue 动态数据滚动

發(fā)布時間:2025/3/12 vue 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Vue 动态数据滚动 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

使用Vue動態(tài)滾動(上下滾動)顯示將要展示的訊息。

代碼分析:
1.設(shè)置固定樣式的框架內(nèi)容
2.設(shè)置紅色字體內(nèi)容是動態(tài)變化的
3.滾動效果為向上滾動

效果演示:

此效果圖的數(shù)據(jù)是不停滾動變化的

第二張效果圖

代碼演示:

注意:引入vue.min.js架包

  • CSS樣式
  • <style> div, ul, li, span, img {margin: 0;padding: 0;display: flex;box-sizing: border-box; } .marquee {width: 100%;height: 50px;align-items: center;color: #3A3A3A;background-color: #b3effe;display: flex;box-sizing: border-box; }.marquee_title {padding: 0 20px;height: 30px;font-size: 14px;border-right: 1px solid #d8d8d8;align-items: center; }.marquee_box {display: block;position: relative;width: 60%;height: 30px;overflow: hidden; }.marquee_list {display: block;position: absolute;top: 0;left: 0; } .marquee_top {transition: all 0.5s;margin-top: -30px }.marquee_list li {height: 30px;line-height: 30px;font-size: 14px;padding-left: 20px; }.marquee_list li span {padding: 0 2px; }.red {color: #FF0101; }</style>
  • Body內(nèi)容
  • <body><div class="vueBox"><div class="marquee"><div class="marquee_title"><span>最新訊息</span></div><div class="marquee_box"><ul class="marquee_list" :class="{marquee_top:animate}"><li v-for="(item, index) in marqueeList"><span>今天</span><span class="red">{{item.name}}</span><span>特價,僅需</span><span class="red"> {{item.value}}</span><span>元一斤,趕快搶購吧!!!</span></li></ul></div></div> </div> </body>
  • Vue內(nèi)容
  • <script type="text/javascript">const vm = new Vue({el: ".vueBox",data: {animate: false,marqueeList: [{name: '蘋果',value: '1.68',},{name: '橘子',value: '0.9',},{name: '香蕉',value: '2.58',},{name: '獼猴桃',value: '3.2',}]},created: function () {setInterval(this.showMarquee, 2000)},methods: {showMarquee: function () {this.animate = true;setTimeout(()=>{this.marqueeList.push(this.marqueeList[0]);this.marqueeList.shift();this.animate = false;},500)},}}); </script>

    如果對上面分步代碼有點不理解的話請看下面整體代碼。

    整體代碼演示

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript" src="js/vue.min.js"></script> <style> div, ul, li, span, img {margin: 0;padding: 0;display: flex;box-sizing: border-box; } .marquee {width: 100%;height: 50px;align-items: center;color: #3A3A3A;background-color: #b3effe;display: flex;box-sizing: border-box; }.marquee_title {padding: 0 20px;height: 30px;font-size: 14px;border-right: 1px solid #d8d8d8;align-items: center; }.marquee_box {display: block;position: relative;width: 60%;height: 30px;overflow: hidden; }.marquee_list {display: block;position: absolute;top: 0;left: 0; } .marquee_top {transition: all 0.5s;margin-top: -30px }.marquee_list li {height: 30px;line-height: 30px;font-size: 14px;padding-left: 20px; }.marquee_list li span {padding: 0 2px; }.red {color: #FF0101; }</style></head> <body><div class="vueBox"><div class="marquee"><div class="marquee_title"><span>最新訊息</span></div><div class="marquee_box"><ul class="marquee_list" :class="{marquee_top:animate}"><li v-for="(item, index) in marqueeList"><span>今天</span><span class="red">{{item.name}}</span><span>特價,僅需</span><span class="red"> {{item.value}}</span><span>元一斤,趕快搶購吧!!!</span></li></ul></div></div> </div> </body> <script type="text/javascript">const vm = new Vue({el: ".vueBox",data: {animate: false,marqueeList: [{name: '蘋果',value: '1.68',},{name: '橘子',value: '0.9',},{name: '香蕉',value: '2.58',},{name: '獼猴桃',value: '3.2',}]},created: function () {setInterval(this.showMarquee, 2000)},methods: {showMarquee: function () {this.animate = true;setTimeout(()=>{this.marqueeList.push(this.marqueeList[0]);this.marqueeList.shift();this.animate = false;},500)},}}); </script> </html>

    掃一掃關(guān)注我的公眾號獲取更多資訊呦!!!

    總結(jié)

    以上是生活随笔為你收集整理的Vue 动态数据滚动的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。