晚上好!我正在嘗試在 Vue 中創建一個頁面,將其決議為組件,并使用 json 呈現內容。而且好像沒什么復雜的,但是有問題。但是為什么href引數放錯了地方呢?請告訴我,我已經有幾個小時無法解開這個謎語了。
索引.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>
英雄.vue
<template>
<div>
<h2>{{ title }}</h2>
<p>{{ description }}</p>
<a :href="href">{{ more }}</a>
</div>
</template>
<script>
結果
<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>
uj5u.com熱心網友回復:
您可能忘記將 href 定義為 Hero 組件中的道具。
確保你在 Hero 組件中添加了 href 作為 prop。
props: {
href: {
type: String,
required: true
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/457859.html
標籤:javascript html css Vue.js Vue组件
