[Vuejs]-Vue :click is being triggered automatically inside v-for

6👍

Should be:

@click="removeItem(item.id)"

Not:

:click="removeItem(item.id)"

When you have :click="removeItem(item.id)" you are actually binding the result of the removeItem(item.id) method call to the click property. Which is why the method executes "automatically".

@click="handler" is a shorthand to v-on:click="handler" – the event handling directive.

:click="handler" is a shorthand to v-bind:click="handler", the property binding directive.

Leave a comment