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

238
Visualizações
Vue Checkbox get an array value but want Array of JSON Objects

enter image description here

<checkbox-group @change="checkboxChange">
                <label class="uni-list-cell uni-list-cell-pd" v-for="item in items" :key="item.value">
                    <view>
                        <checkbox :value="item.value" :checked="item.checked" />
                    </view>
                    <view>{{item.name}}</view>
                </label>
            </checkbox-group>

The data variable from the checkbox is

items: [
        {
           value: 'USA',
           name: 'American'
        },

         {
           value: 'JPN',
           name: 'Japan'
         },
         {
           value: 'ENG',
           name: 'England'
         },
         {
           value: 'FRA',
           name: 'France'
         }
 ]

When check the box for selecting different countries, will get this value. ["JPN", "ENG"]

checkboxChange: function(e) {
                var items = this.items,
                      values = e.detail.value; 
            
                console.log(values) #get value ["JPN", "ENG"]
}

But the desired result is Array of JSON Objects like below

new_items: [ 
       {
         value: 'JPN',
         name: 'Japan'
       },
       {
         value: 'ENG',
         name: 'English'
       }
]

How can I use this value ["JPN", "ENG"] to map with checkbox items to get new_items?

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

Try to bind the whole object to the value prop :

<checkbox :value="item" :checked="item.checked" /> 
about 4 years ago · Santiago Gelvez 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