0
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 object, I want all of the "text" object to be cycled once with a v-for. Is it possible? I've been trying for hours whatever I do I can't get at the end of it.

1
  • Hint: you need two for loop Commented Jan 24, 2022 at 4:10

1 Answer 1

2

The arrays should be rendered with the v-for directive, nesting the v-for for the nested array:

<ul>
  <li v-for="person in people" :key="person.nome">
    <span>{{ person.nome }}</span>
    <ul>
      <li v-for="msg in person.messaggi" :key="msg.date">{{ msg.text }}</li>
    </ul>
  </li>
</ul>

demo

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.