【发布时间】:2020-09-17 00:59:13
【问题描述】:
我有一个 django rest_framework 作为服务器和 vuejs 作为客户端。有一个像“/”这样的索引页面,我在其中使用 v-for 迭代对象数组以显示某些项目的卡片。每张卡都有一个指向“/info”的按钮(在路由器中使用 /:slug 动态更改),如下所示:
...
<RouterLink :to="{name: 'contentItemInfo', params: {item: item, slug: item.slug} }">
<button class="card-button btn fade-in">
...
</button>
</RouterLink>
...
然后,当我们按下按钮时,我们将转到 '/:slug' 并将 item 参数传递给 props,像这样使用它:
...
<video class="video" type="video/mp4" autoplay loop :src="item.trailer"/>
<h3 class="video-info-h3 px-5 py-1 rounded">{{ item.title }}</h3>
<h5 class="video-info-h5 px-5 py-1 rounded">{{ item.subtitle }}</h5>
<p class="video-info-p px-5 py-1 text-wrap rounded">{{ item.description }}</p>
...
export default {
name: "ContentItemInfo",
components: {Footer, Navbar},
props: [
'item'
],
}
暂时有效,但是当我重新加载页面时,所有内容都消失了,并且所有项目的值都未定义
重新加载后我应该如何让它工作?
【问题讨论】:
标签: vue.js