v-bind="{ remoteMethod: remoteMethod.bind(null,index) }"将当前的索引传递到方法中,告诉下面当前要修改的值:
<el-select
v-model="item.materialCode"
filterable
remote
reserve-keyword
no-data-text
placeholder="请输入关键词"
v-bind="{ remoteMethod: remoteMethod.bind(null,index) }"
:loading="loading"
style="width: 280px;">
<el-option
v-for="newItem in item.materialArr"
:key="newItem.materialCode"
:label="`${newItem.materialCode}-${newItem.materialName}`"
:value="newItem.materialCode">
</el-option>
</el-select>
方法:
remoteMethod(index, query) {
const that = this
if (query !== '') {
that.loading = true
crudTransfer.getMaterial(query).then(res => {
that.loading = false
that.form.children[index].materialArr = res
}).catch(err => {
})
} else {
that.form.children[index].materialArr = []
}
},