我有一个叫
Subscribers
通过参数从另一个名为
Details
. 我使用接收到的props进行API调用以获取订户列表。这很管用。
但刷新页面时会出现问题。通过参数传递的ID丢失-变为空。原因
subscribers
定义为数据中的空数组的值将变为未定义的值,如此错误所示:
TypeError: Cannot read property 'length' of undefined
这就是我传递参数的方式
细节
成分
<router-link class="unsubscribe" :to="{ name: 'fund-subscribers', params: {fundProp: fund, id: fund.id } }">View all subscribers to this fund</router-link>
然后我有了这个:
props: {
fundProp: {
type: Object,
default() {
return {
id: null,
title: '',
description: ''
};
}
},
},
data() {
return {
fund: this.fundProp,
subscribers: [],
}
},
这是的路由配置代码
fund-subscribers
{
path: 'funds/:id/subscribers',
name: 'fund-subscribers',
component: Subscribers,
meta: {
title: 'Admin'
},
props: true
},
我可能做错什么了?