I found this script and works fine when you click on the button. What i want to achieve is when the page load it automatic scrolls to that specific div.
How can i achieve that?
<button id="goto" @click="goto('porto')">Go to porto</button>
<div class="page" ref="porto">
Porto page
</div>
methods: {
goto(refName) {
var element = this.$refs[refName];
console.log(element);
var top = element.offsetTop;
window.scrollTo(0, top);
}
},