Reputation: 382
I have problem with binding data in VueJS. In code below, user.name
is working but user.id
in href
attribute is not.
<ul id="message-user-list">
<li v-for="user in users">
<a href="chat.php?user={{ user.id }}">{{ user.name }}</a>
</li>
</ul>
I also tried this but it doesn't work:
<ul id="message-user-list">
<li v-for="user in users">
<a v-bind:href="chat.php?user={{ user.id }}">{{ user.name }}</a>
</li>
</ul>
What do I do wrong? Help please.
Upvotes: 1
Views: 6043
Reputation: 740
Try it like this <a :href="'chat.php?user=' + user.id">{{ user.name }}</a>
If you do v-bind:
- vue takes everything in quotes for js
Upvotes: 13