0👍
✅
You have to define the function in the methods object. Or – if you use the composition-api – return the function from the setup
fuction.
<script>
let navbar_nav = document.getElementById("navbar_nav");
export default {
methods: {
update_nav_bar(elem) {
navbar_nav.getElementsByClassName("active")[0].classList.remove("active");
elem.classList.add("active");
}
}
}
</script>
But maybe you should rethink the function in general. Usually you can achieve this without manipulating the DOM manually with JavaScript.
Source:stackexchange.com