VUE實現(xiàn)吸底按鈕
更新時間:2021年03月04日 08:50:38 作者:前端楊小白
這篇文章主要為大家詳細介紹了VUE實現(xiàn)吸底按鈕,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了VUE實現(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 :class="['go', { isFixed: headerFixed }]" 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>
效果圖:
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Vue?+?Element?實現(xiàn)按鈕指定間隔時間點擊思路詳解
這篇文章主要介紹了Vue?+?Element?實現(xiàn)按鈕指定間隔時間點擊,實現(xiàn)思路大概是通過加一個本地緩存的時間戳,通過時間戳計算指定時間內(nèi)不能點擊按鈕,具體實現(xiàn)代碼跟隨小編一起看看吧2023-12-12Vue Cli與BootStrap結(jié)合實現(xiàn)表格分頁功能
這篇文章主要介紹了Vue Cli與BootStrap結(jié)合實現(xiàn)表格分頁功能,需要的朋友可以參考下2017-08-08Vue-router的使用和出現(xiàn)空白頁,路由對象屬性詳解
今天小編就為大家分享一篇Vue-router的使用和出現(xiàn)空白頁,路由對象屬性詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-09-09