国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

vue實現簡單跑馬燈效果

瀏覽:112日期:2023-01-18 18:43:11

本文實例為大家分享了vue實現簡單跑馬燈效果的具體代碼,供大家參考,具體內容如下

如下圖片,會自行向 上“滾動”

vue實現簡單跑馬燈效果

代碼:

<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <title>跑馬燈 </title> <script src='https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.min.js'></script> <style> div, ul, li, img { margin: 0; padding: 0; box-sizing: border-box; display: flex; } .horseLamp { width: 100%; height: 50px; align-items: center; background-color: #ddd; display: flex; box-sizing: border-box; } .horseLamp_box { display: block; position: relative; width: 60%; height: 30px; overflow: hidden; } .horseLamp_list { display: block; position: absolute; top: 0; left: 0; } .horseLamp_top { transition: all 0.2s; margin-top: -30px } .horseLamp_list li { height: 30px; line-height: 30px; font-size: 14px; } </style> </head><body> <div class='vueBox'> <div class='horseLamp'> <div class='horseLamp_box'> <ul :class='{horseLamp_top:animate}'> <li v-for='(item, index) in horseLampList'> <img :src='http://www.intensediesel.com/bcjs/item.img'> </li> </ul> </div> </div></div> <script type='text/javascript'> const vm = new Vue ({ el: '.vueBox', data: { animate: false, horseLampList: [ { img:’../assets/logo.png’ }, { img:’../assets/logo.png’ }, { img:’../assets/logo.png’ }, { img:’../assets/logo.png’ } ] }, created: function () { setInterval (this.showhorseLamp, 600) }, methods: { showhorseLamp: function () { this.animate = true; setTimeout (() => { this.horseLampList.push (this.horseLampList[ 0 ]); this.horseLampList.shift (); this.animate = false; }, 2000); } } });</script> </body></html>

更多文章可以點擊《Vue.js前端組件學習教程》學習閱讀。

關于vue.js組件的教程,請大家點擊專題vue.js組件學習教程進行學習。

更多vue學習教程請閱讀專題《vue實戰教程》

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Vue
相關文章:
主站蜘蛛池模板: 化州市| 昌图县| 长汀县| 上饶市| 株洲市| 抚宁县| 高陵县| 淳安县| 彭州市| 疏附县| 镇宁| 蓬莱市| 荥阳市| 砀山县| 普洱| 贵州省| 安义县| 宜丰县| 永城市| 荣成市| 大名县| 汝南县| 凭祥市| 石狮市| 鄂州市| 开远市| 道孚县| 抚远县| 金溪县| 寿阳县| 合山市| 肃北| 隆子县| 兰坪| 宁陕县| 铜陵市| 泗阳县| 天气| 侯马市| 晋州市| 夏邑县|