How to pass a dynamic argument to a method in Vue.js?

Asked

Viewed 191 times

1

I need to call a v-on:click event with a dynamic argument.

I tried in the most logical way:

v-on:click="my_method({{value}})".

Doesn’t work.

1 answer

1

Just do it like this:

v-on:click="my_method(value)"

You do not need to use interpolation within dynamic HTML attributes. In Vuejs 2 any interpolation attempt on attributes generates an error message.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.