[Vuejs]-Vue.js pass function to component as prop

0👍

Change your binding expression from

:s_onchange="doo()"

to

:s_onchange="doo"

doo() will call the function straight away at binding time and pass the result of that call to the s_onchange prop, whereas doo simply passes the function instance itself.

I should also mention, this situation should make use of events instead of passing a function with a prop (unless you have some specific reason why you require a function prop instead of an event).

Leave a comment