<el-table :data="tableData" style="width: 100%" @row-click="openDetails(id)">
  <el-table-column prop="wName" label="公众号名称"></el-table-column>
  <el-table-column prop="wID" label="公众号ID"></el-table-column>
  <el-table-column prop="seller" label="商家名称"></el-table-column>
  <el-table-column prop="sign" label="签约状态"></el-table-column>
  <el-table-column prop="amount_1" label="收款总额"></el-table-column>
  <el-table-column prop="amount_2" label="退款总额"></el-table-column>
  <el-table-column prop="amount_3" label="代收总额"></el-table-column>
  <el-table-column prop="amount_4" label="保证金"></el-table-column>
  <el-table-column prop="date" label="签约日期"></el-table-column>
  <el-table-column prop="status" label="状态"></el-table-column>
</el-table>

该如何把一行数据的id放到@row-click里面当作参数传递呢?

export default {
    data () {
        return {
            tableData: [
                {
                    id: '1',
                    wName: 'xxx公众号1',
                    wID: 'zjfiawsf',
                    seller: 'xxxxx公司xxxxx公司xxxxx公司',
                    sign: '已签约',
                    amount_1: '14614.00',
                    amount_2: '0.00',
                    amount_3: '322.00',
                    amount_4: '32122.00',
                    date: '2019-08-09',
                    status: '未冻结'
                },
                {
                id: '2',
                    wName: 'xxx公众号2',
                    wID: 'zjfiawsf',
                    seller: 'xxxxx公司xxxxx公司xxxxx公司',
                    sign: '已签约',
                    amount_1: '14614.00',
                    amount_2: '0.00',
                    amount_3: '322.00',
                    amount_4: '32122.00',
                    date: '2019-08-09',
                    status: '未冻结'
                }
            ]
        }
    },
    methods: {
        //打开详情页弹窗
        openDetails(id) {
          console.log(id)
        },
    }
}
// 文档中有:row-click    当某一行被点击时会触发该事件    三个参数:row, event, column
methods: {
    //打开详情页弹窗
    openDetails(row) {
      console.log(row.id);
    },
}

row-click返回了三个参数 row, eventcolumn

row-click 当某一行被点击时会触发该事件 row, event, column
在作用域中没有id这个变量,所有点击行会报错。
不应该传递参数,element本身对row-click这个事件自动注入了必要的参数(row, event, column),若传入的openDetails原理是注册一个钩子回调而已。

 

转载于:https://www.cnblogs.com/mophy/p/8604697.html

GitHub 加速计划 / eleme / element
54.06 K
14.63 K
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:3 个月前 )
c345bb45 7 个月前
a07f3a59 * Update transition.md * Update table.md * Update transition.md * Update table.md * Update transition.md * Update table.md * Update table.md * Update transition.md * Update popover.md 7 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐