0

For some reason, I receive "Uncaught ReferenceError: quizz is not defined" if I call a function.

<script setup>
import { defineProps } from "vue";
import { useRouter } from "vue-router";

const router = useRouter();

const props = defineProps(["quizz"]);

const navigateToQuiz = () => {
  router.push(`/quizz/${quizz.id}`);
};
</script>
<template>
  <div class="card" @click="navigateToQuiz">
    <img :src="quizz.img" :alt="quizz.name" />
    <div class="card-text">
      <h2>{{ quizz.name }}</h2>
      <p>{{ quizz.questions.length }} questions</p>
    </div>
  </div>
</template>

What should I do? Thanks!

If I do the router.push directly to the @click, it works and takes me to the next page (/quizz/:id)

1 Answer 1

1

Try with ${props.quizz.id} in your function

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.