если у тебя ни одно из условий не выполнится что вернет activeRoute
Код всего компонента.
Не работает только activeRoute, все остальное работает. Почему так? Если все удалить и оставить только activeRoute, то он работает.
data() {
return {
refreshing: false
};
},
beforeRouteEnter(to, from, next) {
if (Store.page.home.page === 0) {
if (typeof app != 'undefined') {
app.$Progress.start();
}
Store.page.home.getSubmissions(to.query.sort).then(() => {
next((vm) => vm.$Progress.finish());
});
} else {
next();
}
},
beforeRouteUpdate(to, from, next) {
if (to.hash !== from.hash) return;
Store.page.home.clear();
this.$Progress.start();
Store.page.home.getSubmissions(to.query.sort).then(() => {
this.$Progress.finish();
next();
});
},
created() {
this.setPageTitle('Voten: ' + Laravel.title, true);
this.startTour();
this.$eventHub.$on('refresh-home', this.refresh);
},
beforeDestroy() {
this.$eventHub.$off('refresh-home', this.refresh);
},
computed: {
cantLoadMore() {
return this.loading || this.NoMoreItems || this.nothingFound;
},
NoMoreItems() {
return Store.page.home.NoMoreItems;
},
nothingFound() {
return Store.page.home.nothingFound;
},
submissions() {
return Store.page.home.submissions;
},
loading() {
return Store.page.home.loading;
},
sort() {
return this.$route.query.sort ? this.$route.query.sort : 'hot';
},
page() {
return Store.page.home.page;
},
uniqueList() {
return _.uniqBy(this.submissions, 'id');
}
},
methods: {
loadMore() {
console.log('load more');
Store.page.home.getSubmissions(this.sort);
},
refresh: _.debounce(
function() {
this.refreshing = true;
Store.page.home.clear();
Store.page.home
.getSubmissions(this.sort)
.then(() => {
this.refreshing = false;
})
.catch(() => {
this.refreshing = false;
});
},
200,
{ leading: true, trailing: false }
),
submit() {
this.$eventHub.$emit('submit');
},
startTour() {
if (this.$route.query.newbie == 1) {
Store.tour.show = true;
}
}
},
computed: {
submitURL() {
return this.$route.params.name
? '/submit?channel=' + this.$route.params.name
: '/submit';
}
},
computed: {
activeRoute() {
if (this.$route.name === 'home') {
return 'home';
}
if (
this.$route.name === 'bookmarked-submissions' ||
this.$route.name === 'bookmarked-comments' ||
this.$route.name === 'bookmarked-users' ||
this.$route.name === 'bookmarked-channels'
) {
return 'bookmarks';
}
if (this.$route.params.username == auth.username) {
return 'profile';
}
if (this.$route.name === 'submit') {
return 'submit';
}
},
unreadNotifications() {
return Store.state.notifications.filter(
(item) => item.read_at == null
).length;
},
unreadMessages() {
return Store.state.contacts.filter(
(item) =>
item.last_message.author.id != auth.id &&
item.last_message.read_at == null
).length;
}
},
methods: {