My Vue.js method is set up like this. In the changeRoute function, I am able to change the class name by using e.target.className = 'clicked';
. However, I am facing difficulty when trying to remove that class name from other elements using pre.removeClass('clicked');
. How can I achieve this?
<script>
export default {
components: {
},
data() {
return {
}
},
methods: {
changeRoute(e, route) {
var pre = this.$el.querySelector('.clicked');
if(pre) {
// pre.removeClass('clicked');
}
this.$router.push({
name: route
});
e.target.className = 'clicked';
}
},
mounted() {
this.$nextTick(() => {
})
}
}
</script>
Also, is there a way to push a class name without replacing all by using e.target.className = 'clicked';
?