Element: el-select remote-method could not support custom reference

Created on 4 Mar 2018  ·  5Comments  ·  Source: ElemeFE/element

Existing Component

Component Name

el-select

Description

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.

Most helpful comment

:remote-method="data => querySpuAttrNames(data,index)"

All 5 comments

Translation of this issue:

Existing Component

yes

Component Name

El-select

Description

I wrote this before

.

V-model= "spuAttrModule.spuAttrValues[index].attrName"
Allow-create

Filterable
Remote

Remote-method= "querySpuAttrNames (data, index)"
Default-first-option

Loading= "spuAttrModule.attrNameListLoading"
@change= "spuAttrNameSelectedOnChange (index)"

>

V-for= "item in spuAttrModule.optNames[index]"
Key= "item.id"

Label= "item.attrName"
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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FranzSkuffka picture FranzSkuffka  ·  3Comments

yuchonghua picture yuchonghua  ·  3Comments

chao-hua picture chao-hua  ·  3Comments

zhguokai picture zhguokai  ·  3Comments

PanJiaChen picture PanJiaChen  ·  3Comments