vue實(shí)現(xiàn)簡(jiǎn)單跑馬燈效果
本文實(shí)例為大家分享了vue實(shí)現(xiàn)簡(jiǎn)單跑馬燈效果的具體代碼,供大家參考,具體內(nèi)容如下
如下圖片,會(huì)自行向 上“滾動(dòng)”

代碼:
<!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.leifengta.com.cn/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>
更多文章可以點(diǎn)擊《Vue.js前端組件學(xué)習(xí)教程》學(xué)習(xí)閱讀。
關(guān)于vue.js組件的教程,請(qǐng)大家點(diǎn)擊專題vue.js組件學(xué)習(xí)教程進(jìn)行學(xué)習(xí)。
更多vue學(xué)習(xí)教程請(qǐng)閱讀專題《vue實(shí)戰(zhàn)教程》
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. php模擬實(shí)現(xiàn)斗地主發(fā)牌2. Python random庫(kù)使用方法及異常處理方案3. 理解PHP5中static和const關(guān)鍵字4. spring acegi security 1.0.0 發(fā)布5. Vue封裝一個(gè)TodoList的案例與瀏覽器本地緩存的應(yīng)用實(shí)現(xiàn)6. Vuex localStorage的具體使用7. jQuery 實(shí)現(xiàn)DOM元素拖拽交換位置的實(shí)例代碼8. .Net Core使用Coravel實(shí)現(xiàn)任務(wù)調(diào)度的完整步驟9. vue 使用localstorage實(shí)現(xiàn)面包屑的操作10. MyBatis中的JdbcType映射使用詳解

網(wǎng)公網(wǎng)安備