An Interest In:
Web News this Week
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
- April 19, 2024
- April 18, 2024
- April 17, 2024
October 21, 2021 04:59 am GMT
Original Link: https://dev.to/vickyvn5/after-refresh-scroll-page-to-topmiddlefooter-42bk
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:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To