【发布时间】:2018-04-30 08:09:24
【问题描述】:
在我的项目中,我有一个要显示的购物清单数组。当组件被挂载时,存储被填充(它只包含一个用于记录客户的数组,从 API 数据库服务器获取......没有任何问题)
在显示时,我收到以下消息:
vue.esm.js?efeb:571 [Vue warn]: Property or method "shoppinglists" is not defined on
the instance but referenced during render. Make sure that this property is reactive,
either in the data option, or for class-based components, by initializing the
property.
See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
shoppinglists 属性定义为计算...
computed: {
...mapGetters([ { shoppinglists: 'getShoppingLists' } ])
},
并且商店包含购物清单数组
状态
{
"shoppinglists":
[{"title":"Groceries","items":[{"text":"Bananas","checked":true},
{"text":"Apples","checked":false}],"id":1,"userId":1}],
"isAuthenticated":true,
"currentUserId":1
}
如果我在数据中插入一个道具声明:
data: function () {
return {
shoppinglists: []
}
},
警告消失,但仍然没有显示列表..
可能有什么问题? 感谢反馈
不完全重复的问题,但离this one不远
【问题讨论】:
-
你声明
getShoppingListsgetter了吗?如果是的话,你能发布它的声明吗?