koalaok
koalaok

Reputation: 5740

How to manage v-bind and v-on together, with Vue2?

This is my line of code inside a v-foor loop :

<div class="box-comment" v-for="p in products">
   <span v-on:click="addProduct(@{{ p.sku_f }})" class="btn text-muted pull-right"><i class="fa fa-plus"></i> Add</span>
</div>

I know I can't use moustaches inside attributes. I should use v-bind but in this case I already have a v-on.....

how should apply both?

Upvotes: 0

Views: 49

Answers (1)

Saurabh
Saurabh

Reputation: 73609

If you have used any vue directive, it will automatically interpolate it as vue variable. SO you just need to do following:

<div class="box-comment" v-for="p in products">
   <span v-on:click="addProduct(p.sku_f)" class="btn text-muted pull-right"><i class="fa fa-plus"></i> Add</span>
</div>

Upvotes: 1

Related Questions