код:
computed: {
subscribed: {
get() {
return Store.state.subscribedAt.indexOf(this.list.id) !== -1
? true
: false;
},
set() {
if (Store.state.subscribedAt.indexOf(this.list.id) !== -1) {
let removeItem = this.list.id;
Store.state.subscribedChannels = Store.state.subscribedChannels.filter(
(channel) => channel.id != removeItem
);
let index = Store.state.subscribedAt.indexOf(this.list.id);
Store.state.subscribedAt.splice(index, 1);
return;
}
Store.state.subscribedChannels.push(this.list);
Store.state.subscribedAt.push(this.list.id);
}
},
},
в этот код:
computed: {
showDiscoverChannels() {
return (
this.channels.length < this.channelsLimit &&
!this.subscribedFilter &&
Store.settings.rightSidebar.channelsFilter == 'subscribed'
);
},
channels() {
// subscribed
return Store.state.subscribedChannels;
},
channelsCount() {
return this.channels.length;
},
showChannelAvatars() {
return Store.settings.rightSidebar.showChannelAvatars;
},
channelsLimit() {
return Store.settings.rightSidebar.channelsLimit;
},
filter() {
return Store.settings.rightSidebar.channelsFilter;
},
filterForHumans() {
if (this.filter == 'subscribed') return 'Subscribed Channels';
if (this.filter == 'bookmarked') return 'Bookmarked Channels';
if (this.filter == 'moderating') return 'Moderating Channels';
},
},
т.е. нужно объеденить два computed в один. Но получаю ошибку [Vue warn]: Error in render: "TypeError: Cannot read property 'id' of undefined".
В чем причина? Где ошибка или конфликт в коде? Спасибо.
this.list undefined судя по всему
Обсуждают сегодня