Reputation: 15
I'm trying to use string interpolation to create an href inside a component v-for loop:
<template>
<div class="pa4">
<div v-for="item in navigationItems">
<a href="'#'${item}">{{item}}</a>
</div>
</div>
</template>
<script>
import {mapState} from 'vuex'
export default {
computed: {
...mapState({
navigationItems: state => state.navigationItems
})
}
}
</script>
Navigation items originate in the Vuex store:
export const state = {
navigationItems: ['Home', 'About', 'Blog', 'Contact']
}
Angular JS has an ng-href directive that would be perfect: https://docs.angularjs.org/api/ng/directive/ngHref
When I use v-bind:href="item" I get 'not bound' errors. Any ideas how to pull this off?
Upvotes: 1
Views: 1733