Answer the question
In order to leave comments, you need to log in
Vue array of objects is not reactive?
export default class Menu extends Vue {
@namespace(APP).Getter
isServiceAnime!: boolean;
menuItems: { title: string, icon: string, urlName?: string }[] = [
{
title: this.isServiceAnime ? 'Gallery' : 'Anime',
icon: this.isServiceAnime ? 'fa far fa-image' : 'fa far fa-play',
urlName: this.isServiceAnime ? GALLERY_NAME : ANIME_LIST_NAME,
},
@namespace(APP).Action
useAnimeService!: () => void;
mounted() {
this.useAnimeService(); // gallery
<template :key="this.$route.path">
<div :key="item.title"
v-for="item in this.menuItems"
>
@Module({namespaced: true})
export default class App extends VuexModule {
service: ServiceType = ServiceType.Anime;
public get isServiceAnime(): boolean {
return ServiceType.Anime === this.service;
}
@MutationAction
public async useAnimeService(): Promise<object> {
return {
service: ServiceType.Anime
};
}
@MutationAction
public async useGalleryService(): Promise<object> {
return {
service: ServiceType.Gallery
};
}
}
@Watch('isServiceAnime', {immediate: true, deep: true})
private onValueChange(value: string, oldValue: string) {
console.log(value);
console.log(oldValue);
}
Answer the question
In order to leave comments, you need to log in
public get isServiceAnime(): boolean {
@Watch('isServiceAnime', {immediate: true, deep: true})
yes, I checked the doc here
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question