Skip to content
Advertisement

Vue.js To add class active when click and remove the previous one

I want to achieve this active link on my div element here you can see the example that i want to do with my code

http://jsfiddle.net/fiddleyetu/9ff79/

JavaScript

in here using vue.js i can’t do the active link on my div elements

image 1

enter image description here

here is my code for the elements on which i have to do the links active

JavaScript

js

JavaScript

Advertisement

Answer

I’m new to Vue but an easy way to turn your JQuery example into Vue.js is this: Jsfiddle demo

Basically, you need to store the active element in your Vue data, and set the class based on in. You could use a v-for to render the list.

The HTML part:

JavaScript

The Vue.js:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement