How can you add a dropdown
effect to this menu vertically, so by placing the mouse on it it opens the ul
daughter if it exists.
I thought of doing with v-if
when I clicked on li
parent, but I do not know how to do this without instantiating a object data
for each section ... is there a more suitable alternative? follow the code.
new Vue({
el : '#app',
data : {
modal : {
estilos : {
filhos : {
padding : {
metodo : 'outer'
},
margin : {
metodo : 'outer'
}
}
},
containeres : {
filhos : {
div : {
filhos : {
example : {
metodo : 'outer'
}
}
},
header : {
metodo : 'outer'
}
}
}
}
},
methods : {
teste (item) {
if(this[item]) this[item]();
else console.warn('metodo inexistente')
},
outer () {
alert('outer');
}
}
})
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script><divid="app">
<ul v-for="(item, key) in modal">
<li>
{{key}}
</li>
<ul v-for="(item2, key2) in item.filhos">
<li @click="teste(item2.metodo)">
{{key2}}
</li>
<ul v-for="(item3, key3) in item2.filhos">
<li @click="teste(item3.metodo)">
{{key3}}
</li>
</ul>
</ul>
</ul>
</div>