Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
Vue Checkbox obtiene un valor de matriz pero quiere una matriz de objetos JSON

ingrese la descripción de la imagen aquí

 <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>

La variable de datos de la casilla de verificación es

 items: [ { value: 'USA', name: 'American' }, { value: 'JPN', name: 'Japan' }, { value: 'ENG', name: 'England' }, { value: 'FRA', name: 'France' } ]

Cuando marque la casilla para seleccionar diferentes países, obtendrá este valor. ["JPN", "ESP"]

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

Pero el resultado deseado es una matriz de objetos JSON como a continuación

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

¿Cómo puedo usar este valor ["JPN", "ENG"] para mapear con elementos de casilla de verificación para obtener nuevos_elementos?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Intente vincular todo el objeto a la propiedad de value :

 <checkbox :value="item" :checked="item.checked" />
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!