新增几行的效果:
代码如下:
<el-table-column label="序号">
<template slot-scope="scope">
{{scope.$index+1}}
</template>
</el-table-column>
直接在el-table-column写模版字符串不合法,需要借助插槽slot,如果要在el-table-column插入el-input或者el-select,同样要借助插槽。
scope代表这一行的数据,取这一行的某个属性值可以用scope.row.属性值获取,scope.$index就是这一行在整个el-table中的index,默认从0开始,序号列从1开始,所以scope.$index+1即可。