是
el-select
I wrote this before
<el-select
v-model="spuAttrModule.spuAttrValues[index].attrName"
allow-create
filterable
remote
:remote-method="querySpuAttrNames(data,index)"
default-first-option
:loading="spuAttrModule.attrNameListLoading"
@change="spuAttrNameSelectedOnChange(index)"
>
<el-option
v-for="item in spuAttrModule.optNames[index]"
:key="item.id"
:label="item.attrName"
:value="item">
</el-option>
</el-select>
querySpuAttrNames(query, index) {
this.spuAttrModule.attrNameListLoading = true;
this.spuAttrModule.optNames = [];
this.$axios
.get(NAME_RESOURCE '?value=' query)
.then((resp) => {
if (resp.data.done) {
this.spuAttrModule.optNames[index] = resp.data.data;
this.spuAttrModule.attrNameListLoading = false;
}
})
.catch((error) => {
console.error(error);
});
}
But , when I trigger "querySpuAttrNames" function, the "query" is undefined?
For some reason, I have to pass "index" parameter into this function.
Translation of this issue:
yes
El-select
I wrote this before
. V-model= "spuAttrModule.spuAttrValues[index].attrName" Filterable Remote-method= "querySpuAttrNames (data, index)" Loading= "spuAttrModule.attrNameListLoading" > V-for= "item in spuAttrModule.optNames[index]" Label= "item.attrName"
Allow-create
Remote
Default-first-option
@change= "spuAttrNameSelectedOnChange (index)"
Key= "item.id"
Value= "item" >
.
.
QuerySpuAttrNames (query, index) {
This.spuAttrModule.attrNameListLoading = true;
This.spuAttrModule.optNames = [];
This.$axios
.get (NAME_RESOURCE '? Value=' query)
.then ((RESP) = > {
If (resp.data.done) {
This.spuAttrModule.optNames[index] = resp.data.data;
This.spuAttrModule.attrNameListLoading = false;
}
})
.catch ((error) = > {
Console.error (error);
});
}
.
But, when I trigger "querySpuAttrNames" function, the "query" is undefined?
For some reason, I have to pass "index" parameter into this function.
So I want to know how to pass custom reference , like "index" , into the "querySpuAttrNames" function
:remote-method="data => querySpuAttrNames(data,index)"
it works ,THX !!!
@change
works too.
Most helpful comment
:remote-method="data => querySpuAttrNames(data,index)"