[Vuejs]-Bind value to the link url

1👍

You can simply use + to concatenate the strings here since v-link accepts JavaScript expressions:

<a v-link="'people/edit/' + item.id">Edit</a>

v-link is the directive for enabling user navigation in a router-enabled app. It accepts a JavaScript expression which will be passed to router.go() internally.

https://github.com/vuejs/vue-router/blob/1.0/docs/en/link.md

3👍

You can’t use mustaches into the v-link, v-link is basically vanilla js, and mustaches as templating part are not allowed.

If you are using ES2015, you can go with template strings.

<a v-link="`/people/edit/${item.id}`">Link</a>

2👍

vlink attribute specifies the color of visited links in a document, it’s not used as you have used it. To create link href is used at place of vlink. Eg below

<a href="people/edit/${item.id}"></a>

Leave a comment