Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass a variable on a function inside v-on:click or @click (Vue.js)

I'm developing a system with vuejs right now. I would like to know if how am I going to pass a variable value inside v-on:click or @click? this is my code:

The props.row contains an object with a key of '_id' and what I want to do is to pass that to the function 'view'.

<q-td key="status" :props="props">
  <q-btn
    color="primary"
    label="view"
    v-on:click="view({{props.row._id}})"
    icon="remove_red_eye"
  /> 
</q-td>

The program crashes.

like image 633
Sean Cortez Avatar asked Mar 04 '23 17:03

Sean Cortez


1 Answers

You can directly pass _id in @click without using .native. Do not confuse native events with the Vue events emitted by the component. They are different things.

<q-td key="status" :props="props">
  <q-btn 
    color="primary"
    label="view"
    @click="view(props.row._id)"
    icon="remove_red_eye"
  />
</q-td>

See this Document(https://quasar-framework.org/guide/quasar-upgrade-guide.html#Some-components-need-native-modifier-for-events-now) for more detail.

like image 118
Patel Pratik Avatar answered Mar 10 '23 22:03

Patel Pratik