R
R
r_g_b_a2020-02-17 17:55:52
Vue.js
r_g_b_a, 2020-02-17 17:55:52

How to highlight active submenu item?

Hello. Tell me how to highlight the active submenu item
in this example https://jsfiddle.net/0h87Lsuo/ ? I tried to use the code from the example for a single-level menu, but in this case two items are highlighted at once. How to correctly pass a unique index, or implement it in a different approach?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-02-17
@r_g_b_a

Let active instead of an index contain a reference to the array element itself:

<div @click="active = subcat" :class="{ active: active === subcat }">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question