D
D
Dilik Pulatov2017-07-16 16:20:59
Vue.js
Dilik Pulatov, 2017-07-16 16:20:59

What is the correct way to write variables to an attribute of a Vuejs element?

Hello!
I'm still new to vue
so I have the same problem.

<div class="list-group">
  <template v-for="(user, i) in users">
    <router-link class="list-group-item" to="/user/{{user.id}}">{{ i }}: {{ user.name }}</router-link>
  </template>
</div>

<script>
  export default{
    data(){
      return{
        users:[
          {name:'User 1', id: 45},
          {name:'User 2', id: 55},
          {name:'User 3', id: 63},
          {name:'User 4', id: 82},
          {name:'User 5', id: 16}
        ],
      }
    },
  }
</script>

there in the router-link tag the to attribute how to write variables correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kulakov, 2017-07-16
@dilikpulatov

Try it like this::to="`/user/${user.id}`"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question