VUE實現(xiàn)吸底按鈕
本文實例為大家分享了VUE實現(xiàn)吸底按鈕的具體代碼,供大家參考,具體內容如下
<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>
效果圖:
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。
相關文章:
1. ASP常用日期格式化函數(shù) FormatDate()2. 概述IE和SQL2k開發(fā)一個XML聊天程序3. Ajax獲取php返回json數(shù)據(jù)動態(tài)生成select下拉框的實例4. ThinkPHP5 通過ajax插入圖片并實時顯示(完整代碼)5. 刪除docker里建立容器的操作方法6. asp批量添加修改刪除操作示例代碼7. jsp實現(xiàn)登錄界面8. msxml3.dll 錯誤 800c0019 系統(tǒng)錯誤:-2146697191解決方法9. CSS3實現(xiàn)動態(tài)翻牌效果 仿百度貼吧3D翻牌一次動畫特效10. ASP.NET MVC使用異步Action的方法
