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