I am new to VueJS, so please be patient with me.
I am trying to code a function that will scroll to an element with a specific ID when a "?" is used in the URL. I want it to have the same effect as demonstrated here.
My assignment requires me to follow a particular format and use two provided functions without including
document.getElementById(Query.query).scrollIntoView({behavior: "smooth" });
. I managed to achieve the desired result by adding this code, but now I need help separating it into two functions and understanding how to call scrollToHere() with the "el" parameter as well.
The scrollToHere() function is only needed within the anchor() method, so I'm not sure how to incorporate it properly. Additionally, I'm unsure about the purpose of the "el" parameter and how to divide the code effectively. Any advice would be greatly appreciated.
<div id="scroll_here"></div>
methods: {
anchor() {
console.log(Query) //query: "scroll_here"
document.getElementById(Query.query).scrollIntoView({behavior: "smooth" });
},
scrollToHere (el) {
// CODE HERE
},
}