VUE implements bottom suction button

VUE implements bottom suction button

This article example shares the specific code of VUE to implement the bottom suction button for your reference. The specific content is as follows

<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">
 Suction bottom button</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>

Effect picture:

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Vue implements a movable floating button
  • Vue custom instructions generate uuid scroll monitoring code to achieve the tab table ceiling effect
  • Sample code for vue sliding ceiling and anchor positioning
  • Vue realizes the effects of ceiling, anchor point and scroll highlight button
  • Implement a Vue ceiling anchor component method
  • Several layout methods for multi-route table header ceiling in Vue
  • Sample code for Vue development to achieve ceiling effect
  • Vue realizes the ceiling or fixed position display of an element (listening to scroll events)

<<:  How to Easily Remove Source Installed Packages in Linux

>>:  Detailed explanation of the use of Join in Mysql

Recommend

Tips for writing concise React components

Table of contents Avoid using the spread operator...

How to convert a string into a number in JavaScript

Table of contents 1.parseInt(string, radix) 2. Nu...

Summary of methods to clear cache in Linux system

1) Introduction to cache mechanism In the Linux s...

React Hook usage examples (6 common hooks)

1. useState: Let functional components have state...

Detailed tutorial on installing PHP and Nginx on Centos7

As the application of centos on the server side b...

Summary of knowledge points about events module in Node.js

Through the study and application of Node, we kno...

Realize the CSS loading effect after clicking the button

Since there is a button in my company's produ...

Flash embedded in web pages and IE, FF, Maxthon compatibility issues

After going through a lot of hardships, I searched...

Javascript asynchronous programming: Do you really understand Promise?

Table of contents Preface Basic Usage grammar Err...

How to manage large file uploads and breakpoint resume based on js

Table of contents Preface Front-end structure Bac...

Introduction to fork in multithreading under Linux

Table of contents Question: Case (1) fork before ...