[Vuejs]-Trying to get row data onClick

3👍

el-table has a built-in row-click event. Just listen to row-click and do something with the returned item.

<template>
  <el-table
    :data="tableData"
    @row-click="handleRowClick" // this line
    class="padded-table" 
    height="600" 
    style="width: 100%" 
    row-key="id"
  >
  ...
  </el-table>
</template>

<script>
export default {
  ...
  methods: {
    handleRowClick(row) {
      console.log(row);
    }
  }
}
</script>

Leave a comment