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

172
Views
Vuejs 3 Parent child loop on same div

In Vuejs 3, I have parent child json which gives output like below.

    <div class="pbRow">
      <div>1</div>
      <div>2</div>
    </div>
    <div class="pbRow">
      <div>3</div>
      <div>4</div>
    </div>

pbRow is parent and under its child.

Now what I want is, instead of Parent pbRow multiple time, I want it only once and all parent's child in same level like

    <div class="pbRow">
      <div>1</div>
      <div>2</div>
      <div>3</div>
      <div>4</div>
    </div>

That means I only need child elements, ignoring their parent.

Below is my code

    <div class="pbRow" v-bind:key="coursePlatform" v-for="coursePlatform in filteredNestedList">
        <div :id="course.id" class="col4 col3" v-for="course in coursePlatform.courses">
        </div>
    </div>

Is there any way I can achieve what I have mentioned ? As I am not sure

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

0

If I understood you correctly you can prepare your data with computed property and then have one loop:

const app = Vue.createApp({
  data() {
    return {
      filteredNestedList: [{courses:[{id:1},{id:2}]},{courses: [{id:3}]}],
    };
  },
  computed: {
    list() {
      return this.filteredNestedList.map(l => l.courses).flat()
    }
  }
})
app.mount('#demo')
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
<div id="demo">
  <div class="pbRow" v-bind:key="coursePlatform" v-for="coursePlatform in list">
    <div :id="coursePlatform.id" class="col4 col3">{{ coursePlatform.id }}</div>
  </div>
</div>

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!