Home  >  Q&A  >  body text

How to access multiple objects in a nested array using Vue and push them simultaneously?

let app = new Vue({
  el: "#app",
  data: {
    currentperson: -1,
    people: [{
      nome: "Francesco Rossio",
      immagine: "img/profile1.jpg",
      oraUltimoMessaggio: "13:32",
      messaggiNonLetti: "2",
      visibile: true,
      messaggi: [{
        date: '10/01/2020 15:30:55',
        text: 'Hei tu, sei molto carino, sai?',
        status: 'sent'
      }, {
        date: '10/01/2020 15:50:00',
        text: 'Sai che mi piacciono le ciabatte?',
        status: 'sent'
      }, {
        date: '10/01/2020 16:15:22',
        text: 'Ora sai tutto di me.',
        status: 'received'
      }],
    },

This is my array and my objects, I want to loop through all "text" objects once using v-for. Is it possible? I've been trying for hours and no matter what I do, I can't get it done.

P粉035600555P粉035600555189 days ago308

reply all(1)I'll reply

  • P粉980815259

    P粉9808152592024-03-31 00:35:50

    Arrays should be nested into nested arrays using the v-for directive , v-for:

    • {{ person.nome }}
      • {{ msg.text }}

    Demo

    reply
    0
  • Cancelreply