How do you put in a mustache inside a href attribute in the context of vue?
These are all the answers I found that I've been trying to implement into my code
How to pass a value from Vue data to href?
https://www.reddit.com/r/vuejs/comments/4ws0px/why_using_vbindhref_rather_than_a_href_string_a/
My code sample right now is:
...
<ul>
<li v-for="menuItems in MenuItems" class="nav-item">
<a
class="nav-link"
v-bind:href="{{ & menuItems.url}}"
aria-label=“blah”
>{{ menuItems.text }}</a
>
</li>
</ul>
...
export default {
name: 'Nav',
data: {
menuItems: [
{text: 'Item 1', url: '/item-1'},
{text: 'Item 2', url: '/item-2'},
{text: 'Item 3', url: '/item-3'},
{text: 'Item 4', url: '/item-4'}
]
}
}
...
I tried:
1.
<a
class="nav-link"
v-bind:href="{{ & menuItems.url}}"
aria-label="blah"
>{{ menuItems.text }}</a
>
<a class="nav-link" v-bind:href="menuItems.url" aria-label="blah" >{{ menuItems.text }}</a >
<a class="nav-link" v-bind:href="/menuItems.url/" aria-label="blah" >{{ menuItems.text }}</a >
I'm either getting:
Errors compiling template:
invalid expression: Unexpected token { in
{{ & menuItems.url}}
Raw expression: v-bind:href="{{ & menuItems.url}}"
Or a completely empty <ul>
What am I doing wrong? How does this work?