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

Gearman + MySQL to achieve persistence operation example

This article uses the gearman+mysql method to imp...

How to configure VMware virtual machine NAT mode

This article describes the VMware virtual machine...

A detailed introduction to Tomcat directory structure

Open the decompressed directory of tomcat and you...

Detailed explanation of MySQL group sorting to find the top N

MySQL group sorting to find the top N Table Struc...

Detailed explanation of MySql data type tutorial examples

Table of contents 1. Brief Overview 2. Detailed e...

How to build and deploy Node project with Docker

Table of contents What is Docker Client-side Dock...

Summary of the use of Vue computed properties and listeners

1. Computed properties and listeners 1.1 Computed...

W3C Tutorial (5): W3C XML Activities

XML is designed to describe, store, transmit and ...

JavaScript implements password box verification information

This article example shares the specific code of ...

A detailed introduction to the netstat command in Linux

Table of contents 1. Introduction 2. Output Infor...

CSS code abbreviation div+css layout code abbreviation specification

Using abbreviations can help reduce the size of yo...

Basic commands for MySQL database operations

1. Create a database: create data data _name; Two...

Detailed explanation of Vue's sync modifier

Table of contents 1. Instructions 2. Modifiers 3....

10 ways to view compressed file contents in Linux (summary)

Generally speaking, when we view the contents of ...