I'm doing a project in vue.js and I have two situations.
The first is that I am generating a list (which is repeated twice) using a v-for
, which works correctly, but in the console I get the following error:
[Vue warn]: You may have an infinite update loop in a component render function.
I understand that the error has to do with something I'm doing wrong in the loop.
The other problem is that I want to show a menu with v-show
, but for some reason it's not working, and I think all things are in their place. Maybe it has to do with the first problem.
HTML
<template>
<header>
<div>
<div class="right-content">
<ul>
<li v-for="topMenuLink in topMenuLinks" :key="topMenuLink">
<a :href="topMenuLink.url">{{topMenuLink.text}}</a>
</li>
</ul>
<div class="menu">
<a href="javascript:void(0);" class="menu-button" :click="showMenu = !showMenu">Menu</a>
</div>
</div>
</div>
<ul class="dropdown-menu" v-show="showMenu">
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li v-for="topMenuLink in topMenuLinks" :key="topMenuLink"><a :href="topMenuLink.url">{{topMenuLink.text}}</a></li>
</ul>
</header>
</template>
Vue.js
export default {
data() {
return {
showMenu: false,
topMenuLinks: [
{
text: 'Texto 1',
url: ''
},
{
text: 'Texto 2',
url: ''
},
{
text: 'Texto 3',
url: ''
},
{
text: 'Texto 4',
url: ''
}
]
}
}
}