2👍
this
in your method is not pointing to the vue instance, so use a normal function instead of fat arrow function
methods: {
toggle: function(dropDownName) {
if (dropDownName === 'Meer') {
this.dropDownOpen = !this.dropDownOpen
}
console.log(this.dropDownOpen)
return this.dropDownOpen
}
See the warning why you should not use =>
arrow functions with methods
add v-show
attribute like this in your template.
<ul v-show="dropDownOpen" class="drop-down-menu">
- [Vuejs]-VeeValidate – custom validation functions in ES5
- [Vuejs]-How to bind index to value attribute in vuejs
0👍
Do not know exactly but this worked:
methods: {
toggle(dropDownName) {
if (dropDownName === 'Meer') {
this.dropDownOpen = !this.dropDownOpen
}
return this.dropDownOpen
}
},
and template:
<ul>
<li v-for="(navHeading, index) in headerMenuItems" @click="toggle(navHeading.name)">
<icon :glyph="navMenuIconNames[index]" :viewBox="navMenuIconNames[index].viewBox" :height="25" :width="50"></icon>
<span>{{ dropDownOpen }}</span>
<a class="navigation-title" href="#">{{ navHeading.name }}</a>
<ul v-show="dropDownOpen" class="drop-down-menu">
<li v-for="dropDownMenuItem in navHeading.children">
<a class="drop-down-menu-item-title">{{ dropDownMenuItem.name }}</a>
</li>
</ul>
</li>
</ul>
- [Vuejs]-Vue with bootstrap-vue : prevent more than one expanded list-element at all times in list (v-for)
- [Vuejs]-Assign all elements inside object to empty string
Source:stackexchange.com