0
点赞
收藏
分享

微信扫一扫

i春秋web题库——题目名称:SQLi

言午栩 2024-11-05 阅读 7

第一步 :首先要在el-table上对ref属性进行定义,后续用来操作该table。

第二步:为表格绑定 @row-click="rowClick"事件。

el-table定义如下:

<template> 
<el-table
:data="tableData"
ref="customTable"
@row-click="rowClick"
style="width: 100%">

<el-table-column
type="selection"
width="55">

</el-table-column>
<el-table-column
prop="date"
label="日期"
width="180">

</el-table-column>
<el-table-column
prop="name"
label="姓名"
width="180">

</el-table-column>
<el-table-column
prop="address"
label="地址">

</el-table-column>
</el-table>
</template>

第三步: 声明row-click事件函数rowClick。


<script>
export default {
data() {
return {
tableData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1517 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1516 弄'
}]
}
},
methods: {
rowClick(row) {
// 取消所有的选择状态
this.$refs.persTable.clearSelection()
//为选中的复选框设置选中状态
this.$refs.persTable.toggleRowSelection(row)
}
}
</script>
举报

相关推荐

0 条评论