element table展开行(查看详情)的获取


HTML

<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui@2.4.0/lib/index.js"></script>
<div id="app">
<template>
  <el-table ref="table" :data="tableData">
    <el-table-column type="selection"></el-table-column>
    <el-table-column label="日期" prop="date"></el-table-column>
    <el-table-column label="姓名" prop="name"></el-table-column>
    <el-table-column label="操作">
      <template slot-scope="props">
        <el-button type="primary" @click="handleCheck(props.row)">查看</el-button>
      </template>
    </el-table-column>
    <el-table-column type="expand">
      <template slot-scope="props">
        <div>这里是详情内容</div>
      </template>
    </el-table-column>
  </el-table>
</template>
</div>

 

CSS

@import url("//unpkg.com/element-ui@2.4.0/lib/theme-chalk/index.css");

.el-table__expand-column .cell {
  display: none;
}

 

JS

var Main = {
    data() {
      return {
        tableData: [
          {
            date: '2016-05-03',
            name: '王小虎',
            province: '上海',
            city: '普陀区',
            address: '上海市普陀区金沙江路 1518 弄',
            zip: 200333
          }, {
            date: '2016-05-02',
            name: '王小虎',
            province: '上海',
            city: '普陀区',
            address: '上海市普陀区金沙江路 1518 弄',
            zip: 200333
          }
        ]
      }
    },
    methods: {
      handleCheck(row) {
        const $table = this.$refs.table
        
        $table.toggleRowExpansion(row)
        $table.toggleRowSelection(row)
      }
    }
  }
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM