Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

161
Visualizações
Data repeating in different drop-downs : Vue.js

I have one add button, on clicking that button one dropdown should add automatically, and then if I click it again it should again add that dropdown. When one dropdown is added I chose one option from available options and then I clicked the add button again to add one more dropdown below it, the dropdown gets added but it is added with the option that I chose for the first dropdown.

Code: HTML:

<div>
     <button class="button btn-primary" @click="addRow">Add row
     </button>
</div>

<div class="form-group row" v-for="(row,index) in addRowArr">
     <div class="col-md-3">
     <label>DropDown: </label>
     <b-input-group left="<i class='fa fa-location-arrow'></i>">
     <basic-select :options="SupplyChainArray" :selected-option="SupplyChaindata"
                    @select="SupplyChainobject" v-model="SupplyChain" name="SupplyChain"
                    id="SupplyChain" placeholder="Select SupplyChain">
     </basic-select>
     </b-input-group>
     </div>
</div>

Javascript:

export default{
data(){
  return(){
      addRowArr : [],
      SupplyChainArray : [{value:1, text:"B2C_HEAVIES"},
                          {value:2, text:"second"},
                          {value:3, text:"third"}],
      SupplyChaindata: {},
      SupplyChain: '',
       }
     },
methods:{
    addRow(){
      this.addRowArr.push({})
    },
    SupplyChainobject(obj) {
        this.SupplyChaindata = obj;
        this.SupplyChain = obj.value;
    },

}
}

For reference please view the attached image :

Attached image

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It is because you are using a v-model with the same variable for all your dropdowns.

You have to use a different variable por each dropdown. According to your data model maybe SupplyChain must be an object with key->value where key is your SupplyChainArray.text and value is the variable associated to v-model.

     <basic-select :options="SupplyChainArray" :selected-option="SupplyChaindata"
                    @select="SupplyChainobject" v-model="row.value" name="SupplyChain"
                    id="SupplyChain" placeholder="Select SupplyChain">
     </basic-select>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda