VUE實(shí)現(xiàn)吸底按鈕
本文實(shí)例為大家分享了VUE實(shí)現(xiàn)吸底按鈕的具體代碼,供大家參考,具體內(nèi)容如下
<template> <div id='test'> <ul class='list-box'> <li v-for='(item, key) in 50' :key='key'> {{ item }} </li> </ul> <transition name='fade'> <p : v-if='headerFixed'> 吸底按鈕 </p> </transition> </div></template> <script>export default { name: ’test’, data() { return { headerFixed: false, } }, mounted() { window.addEventListener(’scroll’, this.handleScroll) }, destroyed() { window.removeEventListener(’scroll’, this.handleScroll) }, methods: { handleScroll() { const scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop this.headerFixed = scrollTop > 50 }, },}</script> <style lang='scss' scoped='scoped'>#test { .list-box { padding-bottom: 50px; } .go { background: pink; text-align: center; line-height: 50px; width: 100%; } .isFixed { position: fixed; bottom: 0; } .fade-enter { opacity: 0; } .fade-enter-active { transition: opacity 0.8s; } .fade-leave-to { opacity: 0; } .fade-leave-active { transition: opacity 0.8s; }}</style>
效果圖:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. Java8內(nèi)存模型PermGen Metaspace實(shí)例解析2. python如何實(shí)現(xiàn)word批量轉(zhuǎn)HTML3. python excel和yaml文件的讀取封裝4. python3實(shí)現(xiàn)往mysql中插入datetime類(lèi)型的數(shù)據(jù)5. python爬蟲(chóng)實(shí)戰(zhàn)之制作屬于自己的一個(gè)IP代理模塊6. moment轉(zhuǎn)化時(shí)間戳出現(xiàn)Invalid Date的問(wèn)題及解決7. 關(guān)于 Android WebView 的內(nèi)存泄露問(wèn)題8. Docker鏡像管理常用操作代碼示例9. Python中內(nèi)建模塊collections如何使用10. 詳解docker pull 下來(lái)的鏡像都存到了哪里
