熟悉下elementui中tabel组件的scope.row和scope.$index的使用
238
tabel组件的自定义列模板中可以使用scope.row获取当前行的数据,而scope.$index获取的是当前行的数据在数组中的索引(tabel表格绑定的数据是一个数组,数组中每一个对象就相当于一行的数据)
使用如下:<el-table-column prop=”age” label=”年龄”>
<template slot-scope=”scope”>
<span @click=”editor(scope.row,scope.$index)”>编辑</span>
</template>
</el-table-column>1年前