用element的table组件怎么获取每一行的index
点击时可以获取一整行的信息,目前不知道怎么获取index,但是获取index的目的也是获取点击那一行的信息,所以直接用点击返回的信息也算是一种方法。
-table :data="employees" highlight-current-row border style="width: 100%" @row-click="getEmpDetail" @selection-change="ss"><el-table-column label="员工列表" inline-template><div class="empList"><span class="employeeName">{{ row.employee_name }}</span><span class="employeeJob">{{ row.type }}</span></div></el-table-column></el-table>
import ElCheckbox from 'element-ui/packages/checkbox';
import ElTag from 'element-ui/packages/tag';
import Vue from 'vue';
import FilterPanel from './filter-panel.vue';
有一个属性可以获取所有已选择的行。网页链接
<el-table-column label="员工列表" inline-template>
<div class="empList">
<span class="employeeName">{{ row.employee_name }}</span>
<span class="employeeJob">{{ row.type }}</span>
</div>
</el-table-column>
</el-table>
<el-table :data="choosePerData" :row-class-name="rowClassName" @row-click="deletePer">
<el-table-column prop="name" label="姓名"></el-table-column>
<el-table-column prop="upLevel" label="上一级"></el-table-column>
<el-table-column prop="address" label="办公地点"></el-table-column>
<el-table-column prop="all" label="全部资源"></el-table-column>
</el-table>
js:
rowClassName({row, rowIndex}) {
//把每一行的索引放进row
row.index = rowIndex;
},
deletePer(row) {
console.log(row.index)
},
用row-class-name为每行加上index,然后就可以随意获取每行的index啦~