mobiw
mobiw

Reputation: 103

Vue select load optionsafter click

How i can load data after click on vue-select, if i do this it's load aftet two click

 <v2-select style="width:150px;max-width: 150px"
                   @click="loadFormats"
                   :searchable="false"
                   :clearable="false
 "
                   :options="formats"
                   v-model="localSelectedFormat.value"
                   label="nameFormat"
        >

        </v2-select>
loadFormats(){
     this.getFormats().then(res => {
 this.formats = res.data;
...
})

Upvotes: 0

Views: 199

Answers (1)

Shimang He
Shimang He

Reputation: 17

you can remove the click event and call the loadFormats function in the mounted lifecycle hook function. code below:

     <v2-select style="width:150px;max-width: 150px"
                       :searchable="false"
                       :clearable="false"
                       :options="formats"
                       v-model="localSelectedFormat.value"
                       label="nameFormat"
            >
    
      </v2-select>

     mounted(){
       this.loadFormats()
     }


    ```


    

Upvotes: 2

Related Questions