page scroll to top when component load in vue code example
Example 1: scroll to top vue
// add scroll to top when a is clicked (routes)
<a @click="scrollToTop(), goToPricing()">Pricing</a>
methods: {
scrollToTop() {
window.scrollTo(0, 0);
}, goToPricing() {
this.$router.push('/pricing');
}
}
Example 2: scroll to top vue
methods: {
scrollToTop() {
window.scrollTo(0,0);
}
}