下拉框列表的change事件,自带一个参数,就是为下拉框选中的值,但是有时候我们需要在带一个参数过去,就会覆盖原来的参数,要怎么办?
这个时候我们可以借助箭头函数,完美解决传参问题。代码如下:
// An highlighted block
<el-table border stripe :data="searchForm.taxPlanEntityList" style="width: 100%">
<el-table-column label="公司名称" align="center" min-width="140" show-overflow-tooltip>
<template slot-scope="{row,$index}" >
<el-select v-model="row.deptId" placeholder="请选择" @change="(deptId) => handleChangeDeptId(deptId, $index)">
<el-option v-for="item in projectList" :label="item.name" :value="item.deptId" :key="item.deptId"></el-option>
</el-select>
</template>
</el-table-column>
</el-table>
方法如下:
handleChangeDeptId(deptId, index) {
console.log(deptId, index) // 这个就是你传过来的值了
}