11
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【メモ】Vue.js + Element UIのtableでrow-click Table Eventsでクリックされたrowのデータを取得する方法

Last updated at Posted at 2019-03-03

Element UIのTableで row-click が行われた時に登録されていたハンドラ側でrowの値を受け取る方法のメモ。

方法

普通に row-clickイベントに登録した method の引数としてクリックしたrowの値を受け取ることができる。

実装


<template>
  <el-table
    :data="tableData"
  @row-click="handleClick">
    <el-table-column
      prop="name"
      label="Name">
    </el-table-column>
    <el-table-column
      prop="age"
      label="Age">
    </el-table-column>
  </el-table>
</template>

<script>
  export default {
    data() {
      return {
        tableData: [{
          name: '太郎',
          age: 25
        }, {
          name: '二郎',
          age: 26,
        }]
      }
    },
    methods: {
      handleClick(val) {
        console.log(`val = ${JSON.stringify(val)}`)
      }
    }
  };
</script>

結果


val = {"name":"太郎","age":25}

参考にさせていただいたサイト

Component | Element

11
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?