nuxt.jsvuejs3instancenuxt3.jsdefined

Property "product" was accessed during render but is not defined on instance


Sorry for this stupid quastion i'm beginer, i found many answers about this problem, but still can't resolve my issue... Help me please...

I use Nuxt3, and just trying add component to a page, can't understand where my mistake..

The problem is that the page transition animation no longer works, but the component appeared

Component ServiceCard.vue:

<template>
  <div class="w-[600px] h-[400px]">
    <img
      src="@/assets/img/online-store.png"
      alt="oleksii vratskyi - online store project"
      width="600"
      height="400"
    />

    <h5 class="font-bold text-xl text-stone-300 mt-5">Online store</h5>
  </div>
</template>

<script setup>
const { product } = defineProps(["product"])
</script>

Page portfolio.vue:

<main>
  <div class="grid grid-cols-2 place-items-center text-stone-300">
    <div> 
      <ServiceCard :card="product" /> 
    </div>

    <div> 
      <ServiceCard :card="product" /> 
    </div>
  </div>
</main>

</template>

<script>
import { ServiceCard } from '@nuxt/schema';
</script>

Solution

  • I see some issues...

    example

    Component ServiceCard.vue:

    <template>
      <div class="w-[600px] h-[400px]">
        <img
          src="@/assets/img/online-store.png"
          alt="oleksii vratskyi - online store project"
          width="600"
          height="400"
        />
    
        <h5 class="font-bold text-xl text-stone-300 mt-5">Online store</h5>
    
        <!-- use prop if you want to include in the child component... -->
        <h1>{{product}}</h1>
      </div>
    </template>
    
    <script setup>
    // if you're not using the prop, you can remove this prop definition
    const { product } = defineProps(["product"])
    
    </script>
    

    Page PortfolioView.vue:

    <main>
      <div class="grid grid-cols-2 place-items-center text-stone-300">
        <div>
          <!-- if there's no `card` prop defined, no need to send it -->
          <ServiceCard/>
        </div>
    
        <div>
          <!-- ...but if you do want to pass a product -->
          <ServiceCard :product="product"/>
        </div>
      </div>
    </main>
    
    </template>
    
    <script setup>
    // use ⬆setup⬆ here too if you're using setup convention
    
    // just guessing here, but probably where your component might be
    import { ServiceCard } from './components/ServiceCard .vue';
    
    // you can define a product here if you want to pass it to the child component
    const product = {
      name: "such wow🐕"
    }
    </script>