Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
October 21, 2021 04:59 am GMT

After refresh scroll page to Top/Middle/Footer.

Here we learn how can we scroll our page onclick button or after Reload page.

simple we adding ref in our html tags where you want to scroll page.
example
< div class="top" ref="goToTop"> ... < /div >
or
< div class="middle" ref="goToMiddle"> ... < /div >
or
< div class="footer" ref="goToFooter"> ... < /div >

in vue js we handled
// Create method
scrollToElement(ref) {
window.scrollTo(0,0);
this.$scrollTo(ref, 1000);
},

// If want to after refresh then create mounted()

mounted() {
this.scrollToElement(this.$refs.goToTop);
},
// for top use goToTop , for middle use goToMiddle , for footer use

// If want to after onclick then create method
onclickMethod() {
this.scrollToElement(this.$refs.goToTop);
},

I hope it will help you.


Original Link: https://dev.to/vickyvn5/after-refresh-scroll-page-to-topmiddlefooter-42bk

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To