[Vuejs]-In Vue, how do I pass the special $event variable as a paremeter?

0👍

Since your filterTodos has only one parameter which is actually the event you want, it is not compulsory to pass $event in your template. instead, you can just pass the method name as following,

<template>
<div>
      <span>Filter Todos:</span>
      <select @change="filterTodos" />
</div>
</template>

0👍

I realise the fault now… I can’t have that parameter ‘event’ as the only parameter in my filterTodos action. If I do the following then it works and I get the event in my console…

filterTodos({ commit }, event) {
    console.log('Here is the event:', event);
    commit('testForNow');
}

So the first parameter (in this case, { commit }) of an action relates to whatever mutation I’ll be doing later in the tutorial in relation to that action. ‘event’ needs to be my second parameter, even though ‘$event’ is the only argument when I call this action.

Leave a comment