[Vuejs]-Vue js : filter data from API

0👍

You probably want to nest flats inside floors, and then filter the flats based on the current floor. It looks like each flat has a floor property which presumably matches an property in floor. Assuming this is floor.id, you can do something like:

<div v-for="(floor, floor_index) in Building.floors" :key="floor_index">
  <pre>Floor: {{ floor }}</pre>
  <div v-for="(flat, flat_index) in Building.flats" :key="flat_index">
    <pre v=if="flat.floor === floor.id">Flat: {{ flat }}</pre>
  </div>
</div>

Leave a comment