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

150
Views
¿Cómo usar accesorios de matriz en Vue 3?

Tratando de aprender los conceptos básicos, obtuve una matriz en el componente principal (App.vue)

 data() { return { fruits: [ "apple", "pear", "cherry" ], }; },

Quiero poder tener el mismo componente 3 veces para cada fruta.

 <Fruit v-for="(fruit, index) in fruits" :key="index"/>

Y esta es la función de accesorios del componente Fruit.vue (el componente secundario)

 props: { fruits: {type: Array, required: false}, }

¿Cómo debo escribir el código para que muestre cada fruta en su componente "propio" en la etiqueta de Fruit.vue?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Desea tener un componente de fruta que acepte solo una cadena de la matriz.

Componente de fruta

 <template> <div class="fruit"> {{ props.fruit }} </div> </template> <script lang="ts" export default defineComponent({ props: { fruit: { type: String, required: true } } setup(props) { return { props } } } </script>

dentro de app.vue

 <Fruit v-for="fruit in fruits" :key="fruit" :fruit="fruit"/>
about 4 years ago · Juan Pablo Isaza 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!