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

JavaScript implements constellation query function with detailed code

Table of contents 1. Title 2. Code 3. Results IV....

Linux Cron scheduled execution of PHP code with parameters

1. Still use PHP script to execute. Command line ...

Using Apache ab to perform http performance testing

Mac comes with Apache environment Open Terminal a...

MySQL Optimization Summary - Total Number of Query Entries

1. COUNT(*) and COUNT(COL) COUNT(*) usually perfo...

Installing the ping tool in a container built by Docker

Because the Base images pulled by Docker, such as...

Things to note when designing web pages for small-screen mobile devices

The reason is that this type of web page originate...

Example of using js to natively implement year carousel selection effect

Preface Use js to achieve a year rotation selecti...

How to mark the source and origin of CSS3 citations

I am almost going moldy staying at home due to th...

MySQL spatial data storage and functions

Table of contents 1. Data Type 1. What is MySQL s...

CSS3 realizes the childhood paper airplane

Today we are going to make origami airplanes (the...

Nexus uses nginx proxy to support HTTPS protocol

background All company websites need to support t...