qg_java_17137
qg_java_17137

Reputation: 3569

How can I use the variable in router-link?

How can I use the variable in router-link ?

<Col
  span="8"
  v-for="(item,index) in this.data"
  >
    <router-link to='/home/workpanel/true/ + item.name'>

there it can not convert the item.name to the value, it is just the string:

'/home/workpanel/true/ + item.name'

how can I use the variable in the router-link's to ? if I click the link, the browser shows:

http://localhost:8080/home/workpanel/true/%20+%20item.name

Upvotes: 1

Views: 2205

Answers (1)

Fab
Fab

Reputation: 4657

Just add : before to attribute. In this way you can use javascript syntax.

<router-link :to="'/home/workpanel/true/' + item.name">

Upvotes: 2

Related Questions