Answer a question

How can the data associated with a row be obtained from a table with the @row-click event?

In the following example, how do I get the id and the name values of the clicked row?

<q-table
  title="Treats"
  dense
  :data="data"
  :columns="columns"
  row-key="id"
  @row-click="rowclick(evt, row)"
/>

(...)

  methods: {
    rowclick(evt, row){
      alert()
    }
  },

Answers

Try this @row-click="onRowClick".

     <q-table
          title="Treats"
          dense
          :data="data"
          :columns="columns"
          row-key="id"
          @row-click="onRowClick"
        />
      methods: {
        onRowClick (evt, row) {
          console.log('clicked on', row)
        }
      },

Codepen: https://codepen.io/Pratik__007/pen/qBdaeGY

Logo

Vue社区为您提供最前沿的新闻资讯和知识内容

更多推荐