Almost every application displays collections: products, messages, tasks, bookings... and, in Colmena Bookings, rooms. So far we have sidestepped the problem by joining names with commas and writing out four almost identical floor buttons by hand. The v-for directive solves this: it repeats a template fragment for each item in an array, an object or a range of numbers. It looks simple, and at a basic level it is, but it hides a concept that every Vue developer must master: the key, which allows Vue to update lists correctly and efficiently. In this lesson you will see every form of v-for, you will understand what Vue does with keys and why an index will not do as a key, how it detects changes in arrays and how to filter and sort without modifying the original data. By the end, Colmena will have its room catalogue as a real list, with filters by capacity and equipment and sorting by price.

Contents

  1. v-for over arrays
  2. The index and destructuring
  3. v-for over objects
  4. v-for over a numeric range
  5. <template v-for>: repeating several elements
  6. :key: why it is essential
  7. Array change detection
  8. Filtering and sorting with computed properties without mutating the original
  9. Combining v-for and v-if correctly
  10. v-for with components
  11. Case study: the Colmena catalogue with filters and sorting

  1. v-for over arrays

The basic syntax is item in array:

<script setup>
const rooms = [
  { id: 'panal', name: 'Panal Room' },
  { id: 'polen', name: 'Polen Room' },
  { id: 'nectar', name: 'Néctar Room' }
]
</script>

<template>
  <ul>
    <li v-for="room in rooms" :key="room.id">{{ room.name }}</li>
  </ul>
</template>

Result:

<ul>
  <li>Panal Room</li>
  <li>Polen Room</li>
  <li>Néctar Room</li>
</ul>
  • v-for goes on the element that is repeated (the <li>), not on the container (<ul>).
  • room is a variable that only exists inside that element and its children. You can call it whatever you like; use the singular of the array's name.
  • :key="room.id" is a unique identifier for each item. We will explain it in depth in section 6; for now, get into the habit of always including it.
  • You can write of instead of in (room of rooms), as in JavaScript's for...of. Both forms are equivalent.
  • If the array is reactive, the list updates itself when the array changes.

Inside the repeated block you have access to everything in the component, not just the loop variable:

<li v-for="room in rooms" :key="room.id">
  {{ room.name }} {{ room.id === selectedRoomId ? '(selected)' : '' }}
</li>

  1. The index and destructuring

An optional second parameter, in parentheses, gives the item's position (starting at 0):

<li v-for="(room, index) in rooms" :key="room.id">
  {{ index + 1 }}. {{ room.name }}
</li>
<!-- 1. Panal Room / 2. Polen Room / 3. Néctar Room -->

You can also destructure each item, as with a function's parameters:

<li v-for="({ id, name, capacity }, index) in rooms" :key="id">
  {{ index + 1 }}. {{ name }} ({{ capacity }} people)
</li>

Destructuring is convenient when you only use a few properties, but bear in mind that you lose the reference to the whole object (you could not pass room to a function). Use it judiciously.

2.1 Nested lists

A v-for can contain another one. The inner one has access to the outer one's variables:

<li v-for="room in rooms" :key="room.id">
  {{ room.name }}
  <ul>
    <li v-for="item in room.equipment" :key="item">{{ item }}</li>
  </ul>
</li>

Here the inner key is the equipment text itself: it is valid because within a single room no two pieces of equipment are the same. Keys only have to be unique among siblings, not across the whole page.

  1. v-for over objects

v-for also iterates over an object's properties. It receives up to three parameters: value, key and index:

<script setup>
const specs = {
  Floor: 1,
  Capacity: '8 people',
  'Price per hour': '€25.00'
}
</script>

<template>
  <ul>
    <li v-for="(value, key, index) in specs" :key="key">
      {{ index + 1 }}. {{ key }}: {{ value }}
    </li>
  </ul>
  <!-- 1. Floor: 1 / 2. Capacity: 8 people / 3. Price per hour: €25.00 -->
</template>
  • The order of the parameters is value first, the opposite of what might seem intuitive. Writing (key, value) is a frequent mistake.
  • The iteration order is that of Object.keys(): insertion order for string keys.
  • The object's key makes a good :key because it is unique by definition.

This is useful for spec sheets, property tables or settings. If you need a specific order or want to filter properties, convert the object into an array with a computed property.

  1. v-for over a numeric range

With an integer, v-for repeats the block that many times. The range starts at 1, not 0:

<button v-for="floor in 3" :key="floor">Floor {{ floor }}</button>
<!-- Floor 1 · Floor 2 · Floor 3 -->

Perfect for the Colmena building, which has exactly three floors. If you need to start at 0, use floor - 1.

  1. <template v-for>: repeating several elements

Just as with v-if, you can use an invisible <template> to repeat a group of elements without adding a container. It is essential in HTML structures that do not allow wrappers, such as description lists (<dl>), where each term (<dt>) is followed by its description (<dd>):

<dl>
  <template v-for="(value, key) in specs" :key="key">
    <dt>{{ key }}</dt>
    <dd>{{ value }}</dd>
  </template>
</dl>

Result:

<dl>
  <dt>Floor</dt><dd>1</dd>
  <dt>Capacity</dt><dd>8 people</dd>
  <dt>Price per hour</dt><dd>€25.00</dd>
</dl>

In Vue 3, the :key goes on the <template> itself, not on its children.

  1. :key: why it is essential

6.1 What Vue does when a list changes

When a v-for's array changes (it is reordered, filtered or an item is added), Vue does not destroy and recreate the whole list: that would be extremely slow. Instead, it compares the new list of virtual nodes with the previous one and applies the minimum number of changes to the DOM. To make that comparison correctly it needs to know which new item corresponds to which old item. That is what the key is: a stable identity for each item.

flowchart TB
    subgraph BEFORE["Previous list (keys)"]
        A1["panal"] --- A2["polen"] --- A3["nectar"]
    end
    subgraph AFTER["New list after sorting by price (keys)"]
        B1["polen"] --- B2["panal"] --- B3["nectar"]
    end
    A1 -.->|"same key: it is REUSED and MOVED"| B2
    A2 -.->|"same key: it is reused and moved"| B1
    A3 -.->|"same key: it stays put"| B3

With keys, the algorithm works like this:

  1. For each new item, it looks for an old item with the same key.
  2. If it finds one, it reuses its DOM node (and its component, with its state), updates whatever has changed and moves it to its new position.
  3. New items without a match are created; old items that do not appear in the new list are removed (and their components are unmounted).

6.2 What happens with no key, or with the index as the key

Without a key (or with :key="index"), Vue pairs the items by position: the first with the first, the second with the second... and updates the content in place, without moving anything. If each item only displays text, the result looks fine. But if an item has its own state in the DOM or in a component (what has been typed into an <input>, the focus, an animation, a child component's internal state), that state stays in the position; it does not travel with the item.

Check it with this experiment:

<script setup>
import { ref } from 'vue'

const rooms = ref([
  { id: 'panal', name: 'Panal Room', hourlyPrice: 25 },
  { id: 'polen', name: 'Polen Room', hourlyPrice: 15 },
  { id: 'nectar', name: 'Néctar Room', hourlyPrice: 35 }
])

function sortByPrice() {
  rooms.value = rooms.value.toSorted((a, b) => a.hourlyPrice - b.hourlyPrice)
}
</script>

<template>
  <button @click="sortByPrice">Sort by price</button>
  <ul>
    <!-- Try it first with :key="index" and then with :key="room.id" -->
    <li v-for="(room, index) in rooms" :key="index">
      {{ room.name }} <input placeholder="Quick note" />
    </li>
  </ul>
</template>

Type "For the client" in the Panal Room's field and click "Sort by price":

Key Result
:key="index" The names are reordered (Polen, Panal, Néctar), but "For the client" stays in the first field, which now belongs to Polen. A silent bug.
:key="room.id" Panal's <li> is moved as a whole, with its field and its text, to the second position. Correct.

The <input> without v-model has its own state in the DOM, which Vue does not manage. With the index as the key, Vue believes that the item in position 0 is "the same" before and after, and only changes its text.

6.3 Rules for choosing the key

  • Use a unique, stable identifier from the data: room.id, booking.id. Ideally it should come from the data itself (from the database or the API).
  • It must be a string or a number (not an object).
  • It must be unique among siblings in the same v-for.
  • Do not use the index if the list can be reordered or filtered, or if items can be inserted anywhere other than at the end. It is only acceptable in static lists that never change.
  • Do not use random values (Math.random()): they would change on every render and Vue would recreate every item.

The official style guide considers the key in v-for essential, and the ESLint plugin for Vue that you installed flags a v-for without a key as an error.

  1. Array change detection

With the Proxy-based reactivity system you saw in Reactivity: ref and reactive, Vue detects practically any change to a reactive array. There are two ways to change one:

Mutating methods: they modify the original array. Vue intercepts them and updates the view.

Method What it does
push() / pop() Adds / removes at the end
unshift() / shift() Adds / removes at the start
splice() Inserts, removes or replaces at any position
sort() / reverse() Sorts / reverses the original
Assignment by index (array[0] = x) and array.length = 0 Also reactive in Vue 3 (they were not in Vue 2)

Non-mutating methods: they return a new array and leave the original untouched. For the view to change, you have to replace the array:

Method What it returns
filter(), map(), slice(), concat() A new array
toSorted(), toReversed(), toSpliced(), with() Modified copies (ES2023)
const catalog = ref([...])

// Mutation: Vue detects it
catalog.value.push(newRoom)

// Replacement: this works too, and Vue reuses the nodes with the same key
catalog.value = catalog.value.filter((room) => room.available)

Replacing an entire array is not inefficient: thanks to the keys, Vue reuses every item that still exists.

  1. Filtering and sorting with computed properties without mutating the original

The most common need is not to change the data but to display a different view of it: filtered, sorted or both. The right way is a computed property that returns a derived array:

const availableRooms = computed(() => catalog.value.filter((room) => room.available))

const roomsByPrice = computed(() =>
  catalog.value.toSorted((a, b) => a.hourlyPrice - b.hourlyPrice)
)
<li v-for="room in roomsByPrice" :key="room.id">{{ room.name }}</li>

Why not catalog.value.sort(...) inside the computed property? Because sort() sorts the original: it would modify the state from within a computed property (something forbidden, as you saw in 02-05), it would change the order for any other part of the code that uses catalog, and it could cause update loops. Use toSorted() or make a copy first: [...catalog.value].sort(...).

And what if the filter needs a parameter, for example inside a nested v-for? A computed property does not accept arguments, so you can use a function:

<li v-for="room in rooms" :key="room.id">
  <span v-for="item in featuredEquipment(room)" :key="item">{{ item }}</span>
</li>

Remember that the function will run on every render: fine for small lists; for large lists, precalculate the data in a computed property.

  1. Combining v-for and v-if correctly

As we mentioned in Conditional Rendering, do not put v-if and v-for on the same element: v-if has higher priority and cannot see the loop variable. Depending on what you want to achieve:

Filtering items in the list → a computed property (the best option):

<!-- WRONG -->
<li v-for="room in catalog" v-if="room.available" :key="room.id">...</li>

<!-- RIGHT -->
<li v-for="room in availableRooms" :key="room.id">...</li>

What is more, the computed property is calculated once and cached, whereas a v-if per item would be evaluated on every render.

Showing or hiding part of each item → v-if inside the repeated element, or <template v-for> with the v-if on the child:

<template v-for="room in catalog" :key="room.id">
  <li v-if="room.available">{{ room.name }}</li>
</template>

Showing or hiding the whole list → v-if on an outer element:

<ul v-if="catalog.length > 0">
  <li v-for="room in catalog" :key="room.id">{{ room.name }}</li>
</ul>
<p v-else>There are no rooms.</p>

  1. v-for with components

v-for works in exactly the same way on components:

<RoomCard v-for="room in visibleRooms" :key="room.id" :room="room" />

With components, the key is even more important: each component has its own state (such as RoomCard's attendees), and only with a stable key does that state stay with the right room when reordering or filtering.

Notice the :room="room": this is how each card would be passed its own room. Our RoomCard does not yet know how to receive it (it has the Panal Room written inside it), because for that it needs props, which you will see in Props and Custom Events. That is why, in this lesson, we will draw the list directly in App.vue.

  1. Case study: the Colmena catalogue with filters and sorting

We are going to turn the catalogue section of App.vue into a real list with:

  • Floor buttons generated with a range.
  • Filters by minimum capacity and by equipment, in addition to the name search we already had.
  • Sorting by price.
  • Each room's equipment list and a button to select it.
  • A spec sheet for the selected room, using <template v-for> over an object.

11.1 The script

Add these pieces to the <script setup> of src/App.vue. The roomsWithCapacity computed property replaces the previous one (which depended on the booked seats: now the user chooses the capacity) and catalogNames is no longer needed, so you can delete it.

// --- Catalogue filters and sorting ---
const minCapacity = ref(1)
const capacityOptions = [1, 4, 8, 12]
const requiredEquipment = ref('') // '' = any
const sort = ref('none')
const sortOptions = [
  { value: 'none', label: 'Unsorted' },
  { value: 'price-asc', label: 'Cheapest first' },
  { value: 'price-desc', label: 'Most expensive first' }
]

// Every type of equipment in the loaded catalogue, without repeats and in alphabetical order
const catalogEquipment = computed(() => {
  const all = catalog.value.flatMap((room) => room.equipment)
  return [...new Set(all)].sort()
})

const roomsWithCapacity = computed(() =>
  catalog.value.filter((room) => room.capacity >= minCapacity.value)
)

const visibleRooms = computed(() => {
  const filtered = roomsWithCapacity.value.filter(
    (room) =>
      matchesSearch(room) &&
      (requiredEquipment.value === '' ||
        room.equipment.includes(requiredEquipment.value))
  )

  if (sort.value === 'price-asc') {
    return filtered.toSorted((a, b) => a.hourlyPrice - b.hourlyPrice)
  }
  if (sort.value === 'price-desc') {
    return filtered.toSorted((a, b) => b.hourlyPrice - a.hourlyPrice)
  }
  return filtered
})

function toggleEquipment(item) {
  // Clicking the active filter switches it off
  requiredEquipment.value = requiredEquipment.value === item ? '' : item
}

function clearFilters() {
  minCapacity.value = 1
  requiredEquipment.value = ''
  sort.value = 'none'
  clearSearch()
}

function selectRoom(id) {
  selectedRoomId.value = id // the writable computed property takes care of the rest
}

// Spec sheet for the selected room: an object to iterate over with v-for
const specSheet = computed(() => ({
  Floor: selectedRoom.value.floor,
  Capacity: `${selectedRoom.value.capacity} people`,
  'Price per hour': formatPrice(selectedRoom.value.hourlyPrice),
  Equipment: selectedRoom.value.equipment.join(', ')
}))

Key points:

  • catalogEquipment: flatMap gathers the equipment of every room into a single array (with repeats); new Set(...) removes the duplicates and [...] turns it back into an array. Here sort() is safe because it sorts a freshly created array, not the state. Because it depends on catalog, if you filter by floor only that floor's equipment appears.
  • visibleRooms chains the computed properties: it starts from roomsWithCapacity, applies the search (with the search box's matchesSearch function) and the equipment filter, and sorts with toSorted. catalog is never modified.
  • selectRoom(id) assigns the selectedRoomId writable computed property from lesson 02-05: selecting a room resets the seats without our having to repeat that rule.
  • specSheet prepares an object with readable labels as keys. We will iterate over it with v-for.

11.2 The catalogue template

Replace the entire .catalog section:

<section class="catalog">
  <h2>Catalogue</h2>

  <div class="filters">
    <p>
      Floor:
      <button
        class="button"
        :class="{ 'button--active': floorFilter === null }"
        @click="floorFilter = null"
      >
        All
      </button>
      <button
        v-for="floor in 3"
        :key="floor"
        class="button"
        :class="{ 'button--active': floorFilter === floor }"
        @click="floorFilter = floor"
      >
        {{ floor }}
      </button>
    </p>

    <p>
      Minimum capacity:
      <button
        v-for="min in capacityOptions"
        :key="min"
        class="button"
        :class="{ 'button--active': minCapacity === min }"
        @click="minCapacity = min"
      >
        {{ min }}+
      </button>
    </p>

    <p>
      Equipment:
      <button
        v-for="item in catalogEquipment"
        :key="item"
        class="button"
        :class="{ 'button--active': requiredEquipment === item }"
        :aria-pressed="requiredEquipment === item ? 'true' : 'false'"
        @click="toggleEquipment(item)"
      >
        {{ item }}
      </button>
    </p>

    <p>
      Sort:
      <button
        v-for="option in sortOptions"
        :key="option.value"
        class="button"
        :class="{ 'button--active': sort === option.value }"
        @click="sort = option.value"
      >
        {{ option.label }}
      </button>
    </p>
  </div>

  <p v-if="loading" class="state">Loading rooms…</p>

  <div v-else-if="error" class="state state--error" role="alert">
    <p>{{ error }}</p>
    <button class="button" @click="reloadRooms">Retry</button>
  </div>

  <p v-else-if="catalog.length === 0" class="state">
    There are no rooms on this floor. Try "All".
  </p>

  <div v-else-if="visibleRooms.length === 0" class="state">
    <p>No room matches the chosen filters.</p>
    <button class="button" @click="clearFilters">Clear filters</button>
  </div>

  <template v-else>
    <p>
      <strong>{{ freeRooms }}</strong> free rooms out of {{ catalog.length }} ·
      showing {{ visibleRooms.length }}
    </p>

    <ul class="room-list">
      <li
        v-for="room in visibleRooms"
        :key="room.id"
        class="room-list__item"
        :class="{
          'room-list__item--selected': room.id === selectedRoomId,
          'room-list__item--unavailable': !room.available
        }"
      >
        <h3>{{ room.name }}</h3>
        <p>
          Floor {{ room.floor }} · {{ room.capacity }}
          {{ room.capacity === 1 ? 'person' : 'people' }} ·
          {{ formatPrice(room.hourlyPrice) }}/h
        </p>
        <ul class="equipment">
          <li v-for="item in room.equipment" :key="item">{{ item }}</li>
        </ul>
        <button
          class="button"
          :disabled="room.id === selectedRoomId"
          @click="selectRoom(room.id)"
        >
          {{ room.id === selectedRoomId ? 'Selected' : 'Select' }}
        </button>
      </li>
    </ul>
  </template>
</section>

Let's analyse what is new:

  • v-for="floor in 3" generates buttons 1, 2 and 3. The "All" button stays outside the loop because its value (null) is not part of the range.
  • v-for="min in capacityOptions" iterates over an array of numbers; each number is its own key, as none is repeated.
  • v-for="option in sortOptions" iterates over an array of { value, label } objects: the value is stored in the state and the label is displayed. Key: option.value.
  • A fifth state: as well as loading, error, empty and data, we distinguish "the catalogue has rooms, but the filters exclude all of them". The message is different (and offers "Clear filters"), because the solution for the user is different too.
  • The room list uses room.id as its key. When sorting by price, each <li> is moved as a whole.
  • The nested equipment list uses the text itself as its key.
  • The classes mark the selected room and the unavailable ones, combining what you learnt in Class and Style Bindings.

11.3 The spec sheet

In the .selection section, replace the "Floor ... · up to ... people" paragraph with the spec sheet:

<h2>Selected room: {{ selectedRoom.name }}</h2>
<dl class="spec-sheet">
  <template v-for="(value, key) in specSheet" :key="key">
    <dt>{{ key }}</dt>
    <dd>{{ value }}</dd>
  </template>
</dl>

11.4 Styles

Add this to the <style scoped> of App.vue:

.room-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  padding: 0;
  list-style: none;
}

.room-list__item {
  padding: 1rem;
  border: 2px solid transparent;
  border-radius: 10px;
  background: white;
}

.room-list__item--selected {
  border-color: var(--color-honey);
}

.room-list__item--unavailable {
  opacity: 0.6;
}

.room-list__item h3 {
  margin: 0 0 0.5rem;
}

.equipment {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0;
  list-style: none;
}

.equipment li {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--color-background);
  font-size: 0.8rem;
}

.spec-sheet {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
}

.spec-sheet dt {
  font-weight: bold;
}

.spec-sheet dd {
  margin: 0;
}

The list uses CSS Grid with auto-fill: it adapts automatically to the screen width, with as many columns of at least 220 px as will fit.

11.5 Try it

  1. Click "Cheapest first": the order becomes Celda (€6), Polen (€15), Panal (€25), Néctar (€35), Enjambre (€90).
  2. Choose "8+" and "videoconference": Néctar and Enjambre remain.
  3. Search for "panal" with those filters active: the message "No room matches the chosen filters" appears. Click "Clear filters".
  4. Select the Polen Room in the list: its card is highlighted, the "Selected room" section and its spec sheet change, and the seats are reset.
  5. Filter by floor 1: the equipment buttons are reduced to those on that floor.

Common Mistakes and Tips

  • Forgetting the key. ESLint will flag it as an error. Always add it, with a stable identifier.
  • Using the index as the key in lists that change. The items' states (fields, focus, child components) end up in the wrong position.
  • Writing (key, value) when iterating over an object. The order is (value, key, index).
  • Expecting the range to start at 0. v-for="n in 3" produces 1, 2, 3.
  • Sorting with sort() inside a computed property. It mutates the original. Use toSorted() or a copy.
  • Putting v-if and v-for on the same element. Filter with a computed property or split the directives across different elements.
  • Putting the key on the children of a <template v-for>. In Vue 3 it goes on the <template> itself.
  • Tip: if a v-for starts to have a lot of markup per item (like our catalogue <li>), that is the signal that the block should be a component. That is exactly what we will do with RoomCard and RoomList in module 3.

Exercises

Exercise 1. Add a "Largest capacity first" sort option ('capacity-desc') to the catalogue. You should only need to touch two places in the script. Which ones?

Exercise 2. Modify each room's equipment list so that the equipment matching the active filter (requiredEquipment) is highlighted with an equipment__active class. Also add, before each room's name, its position in the visible list ("1.", "2."...).

Exercise 3. A colleague writes this code to show only the available rooms, numbered, and gets errors. Find the three problems and propose a correct version.

<li v-for="(index, room) in catalog" v-if="room.available" :key="index">
  {{ index }}. {{ room.name }}
</li>

Solutions

Solution 1. In the sortOptions array and in the visibleRooms computed property:

const sortOptions = [
  { value: 'none', label: 'Unsorted' },
  { value: 'price-asc', label: 'Cheapest first' },
  { value: 'price-desc', label: 'Most expensive first' },
  { value: 'capacity-desc', label: 'Largest capacity first' }
]

// Inside visibleRooms, before the final return:
if (sort.value === 'capacity-desc') {
  return filtered.toSorted((a, b) => b.capacity - a.capacity)
}

The template does not change: the v-for over sortOptions generates the new button automatically. This is one of the great advantages of generating the interface from data.

Solution 2.

<li v-for="(room, index) in visibleRooms" :key="room.id" ...>
  <h3>{{ index + 1 }}. {{ room.name }}</h3>
  <!-- ... -->
  <ul class="equipment">
    <li
      v-for="item in room.equipment"
      :key="item"
      :class="{ equipment__active: item === requiredEquipment }"
    >
      {{ item }}
    </li>
  </ul>
</li>
.equipment li.equipment__active {
  background: var(--color-honey);
  color: white;
}
  • The index is used to display the position, not as the key: the key is still room.id.
  • The inner v-for accesses the component's requiredEquipment without any problem.
  • We use li.equipment__active in the selector so that it has higher specificity than .equipment li and its background takes precedence.

Solution 3. Problems:

  1. The order of the parameters: for an array it is (item, index), not (index, room).
  2. v-if and v-for on the same element: v-if is evaluated first and room does not exist yet.
  3. The index as the key, and the numbering too: even if items were hidden with v-if, the index would still count the hidden rooms (1, 2, 3, 5...).

Correct version, filtering beforehand with a computed property:

const availableRooms = computed(() => catalog.value.filter((room) => room.available))
<li v-for="(room, index) in availableRooms" :key="room.id">
  {{ index + 1 }}. {{ room.name }}
</li>

Now the numbering is consecutive, because the index corresponds to the already filtered list.

Conclusion

v-for repeats a template fragment for each item in an array (with an optional index and destructuring), each property of an object (value, key, index) or each number in a range starting at 1, and with <template v-for> it can repeat groups of elements without a container. The key gives each item a stable identity: thanks to it, Vue reuses and moves nodes and components instead of rewriting their content by position, which is why it must never be the index in lists that change. Vue detects both mutating methods and array replacement, and the right way to filter and sort is a computed property that does not mutate the original (filter, toSorted), which also solves the combination of v-if with v-for. Colmena Bookings now displays its catalogue as a grid of rooms, with floor, capacity and equipment filters, sorting by price, each room's equipment list, selection from the list and a spec sheet.

We now know how to display data in every possible way. The other half of a booking application is still missing: collecting data. In the next lesson, Forms with v-model, we will build the complete booking form, with every kind of field, validation and price calculation.

New edition · October 2026

Vue.js Course

Module 1: Introduction to Vue.js

Module 2: Vue.js Basics

Module 3: Vue.js Components

Module 4: Vue Router

Module 5: State Management with Vuex and Pinia

Module 6: Vue.js Directives

Module 7: Vue.js Plugins

Module 8: Testing in Vue.js

Module 9: Advanced Vue.js Concepts

Module 10: Building and Deploying Vue.js Applications

Module 11: Real-World Vue.js Projects

© Copyright 2026. All rights reserved