Quiz: An Empty Page
This page should show an order of two items, with a button that adds a third. But the page stays completely empty, and the console says:
TypeError: Cannot read properties of undefined (reading 'length')
Click the line with the mistake.
1<script setup>
2import { ref } from "vue";
3
4const order = ref(["Espresso", "Carrot Cake"]);
5
6function addToOrder(name) {
7 order.value.push(name);
8}
9</script>
10
11<template>
12 <h1>Corner Café</h1>
13 <p class="order">Your order: {{ order.join(", ") }}</p>
14 <p class="count">Items: {{ order.value.length }}</p>
15 <button @click="addToOrder('Mint Tea')">Mint Tea</button>
16</template>