0

Good evening! I'm trying to create a page in Vue, parsing it into components, and rendering content using json. And it seems to be nothing complicated, but there is a problem. But why is the href parameter in the wrong place? Please tell me, I have been unable to solve this riddle for several hours.

index.vue

<template>
  <section>
    <Hero
      v-for="(hero, index) in heroes"
      :title="hero.title"
      :description="hero.description"
      :more="hero.more"
      :href="hero.href"
      :key="index"
    />
  </section>
</template>

Hero.vue

<template>
  <div>
    <h2>{{ title }}</h2>
    <p>{{ description }}</p>
    <a :href="href">{{ more }}</a>
  </div>
</template>
<script>

Result

<section>
  <div href="/create">
    <h2>Create and share your photo stories.</h2>
    <p>
      Photosnap is a platform for photographers and visual storytellers. We make
      it easy to share photos, tell stories and connect with others.
    </p>
    <a>Get an Invite </a>
  </div>
  ...
</section>
2
  • Have you looked at this link? stackoverflow.com/questions/40899532/… Commented Apr 8, 2022 at 0:17
  • 1
    can you share your Hero component as whole ? Commented Apr 8, 2022 at 0:31

1 Answer 1

2

You probably forgot to define href as a prop in your Hero component.

Make sure you have added href as prop in your Hero component.


  props: {
    href: {
        type: String,
        required: true
     }

  }

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.