Get the App
SLTechnology News&Howtos  ›  Development  › 

How does vue achieve the top effect back to the top through v-show

Shulou Source: shulou.com Published: 2022-06-02 06:38:24 11月16日 Update

This article mainly introduces "vue how to achieve the top top effect through v-show". In the daily operation, I believe that many people have doubts about how to achieve the vue back to the top top effect through v-show. The editor consulted all kinds of materials and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the question of "how to achieve the top top effect through v-show". Next, please follow the editor to study!

Html

Top

Css

.totop {width: 50px; height: 50px; line-height: 50px; border-radius: 25px; background-color: white; position: fixed; bottom: 75px; right: 10px; text-align: center;}

Data

Data () {return {toTopShow: false, srcoll: 0,}}

Monitor event

Watch: {srcoll () {if (this.srcoll > 400) {this.toTopShow = true;} else {this.toTopShow = false;},}

Load event

Mounted () {window.addEventListener ("scroll", this.srcollShow);}

Methods:

Methods: {srcollShow () {this.srcoll = window.pageYOffset | | document.documentElement.scrollTop | | document.body.scrollTop;}, toTop () {this.toTopSpeed = setInterval (()) = > {document.documentElement.scrollTop = document.documentElement.scrollTop-20 document.documentElement.scrollTop / delayed scrolling if (this.srcoll < 10) {clearInterval (this.toTopSpeed) by changing the number }, 1);},} at this point, the study on "how to get back to the top top effect by vue through v-show" is over. I hope to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Effects top learning events more help practical next animation numbers articles methods theory knowledge articles websites materials follow questions easy to use Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Information macOS Redmi Xiaomi