简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM