【发布时间】:2021-06-18 21:40:23
【问题描述】:
i get id is not defined ,我的 props 没有传递给组件,这里是索引代码。
id 未定义
<template>
<div class="home-page">
<h1>get latest News</h1>
<post-preview
id="1"
thumbnail="https://cdn.pixabay.com/photo/2015/03/26/09/41/chain-690088_1280.jpg"
previewText="hello first "
title="test"
></post-preview>
</div>
</template>
<script>
import PostPreview from "../components/posts/PostPreview";
export default {
components: { PostPreview }
};
</script>
///////////////// 这是我试图获取道具并使用它的组件。
<template>
<nuxt-link to="/posts/1">
<article class="post-preview">
<div
class="post-thumbnail"
:style="{
backgroundImage: 'url(' + thumbnail + ')'
}"
></div>
<div class="post-content">
<h1>{{ title }}</h1>
<p>{{ previewText }}</p>
</div>
</article>
</nuxt-link>
</template>
<script>
import ref from "vue";
props: [id, title, previewText, thumbnail];
export default {
};
</script>
【问题讨论】:
标签: javascript nuxt.js vuejs3