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 : 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í)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. IntelliJ IDEA安裝插件的方法步驟2. ASP.NET MVC使用typeahead.js實現(xiàn)輸入智能提示功能3. html小技巧之td,div標簽里內(nèi)容不換行4. python 生成正態(tài)分布數(shù)據(jù),并繪圖和解析5. python numpy中setdiff1d的用法說明6. python 中 .py文件 轉(zhuǎn) .pyd文件的操作7. XPath入門 - XSL教程 - 38. Python logging模塊原理解析及應(yīng)用9. Python .py生成.pyd文件并打包.exe 的注意事項說明10. 五分鐘學(xué)會怎么用Pygame做一個簡單的貪吃蛇
