<ul>
<li v-for="item in navList">
<a :href="item.url" :class="item.cls" :title="item.name" @click="isOpen = !isOpen">{{ item.name }}
<ul v-if="item.children" :class="{ isOpen }" class="dropdown">
<li v-for="{ url, name, index } in item.children" :key="index">
<a :href="url" :title="name">{{ name }}
</li>
</ul>
</a>
</li>
</ul>
<div id="navbar">
<block-navigation></block-navigation>
<span>World!</span>
<other-components></other-components>
</div>
Vue.component('block-navigation', {
props: ['val'],
data() {
return {
navlist: [
{ link: 'name-1', name: 'linkName-1' },
{ link: 'name-2', name: 'linkName-2' },
{ link: 'name-3', name: 'linkName-3' },
{ link: 'name-4', name: 'linkName-4' },
{ link: 'name-5', name: 'linkName-5' },
]
}
},
template: `
<ul>
<li
v-for="val in navlist"
:key="val.id">
<a :href=val.link :title=val.name>{{ val.name }}</a>
</li>
</ul>
`
})
new Vue({
el: '#navbar'
})