I am VueJS beginner, so please bear with me.
I need to code to scroll to id element when using “?” in URL. Same effect as this
But I have follow the question with fix format, because this is my assignment. They provided these 2 functions without document.getElementById(Query.query).scrollIntoView({behavior: "smooth" });
. I have completed the result by adding the above code. But I don't know how to separate into 2 functions. And I don't know how to call scrollToHere() with "el" parameter also.
scrollToHere() is not called at other place, so I have to include this function in anchor(), but I have no idea how. What is this "el" for? How do I separate the code? Any guidance would be 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
},
}