Ссылка на магазин Vuex Vuetify - «Ошибка типа: невозможно прочитать свойство 'theme' из undefined» - PullRequest
0 голосов
/ 25 мая 2020

Я хотел бы изменить свойство vuetify из магазина vuex. Из компонента могу делать this.$vuetify.theme.dark = true;. Это невозможно в магазине, но, к сожалению, я получаю ту же ошибку при попытке, например Vue.prototype.$vuetify.theme.dark = true;.

Я получаю ошибку Error in v-on handler: "TypeError: Cannot read property 'theme' of undefined".

В моем основном. js У меня есть следующее:

Vue.use(Vuetify);
const vuetify = new Vuetify({
  theme: {
    dark: true,
    themes: {
      light: {
        primary: colors.purple,
        secondary: colors.grey.darken1,
        accent: colors.shades.black,
        error: colors.red.accent3,
        background: colors.indigo.lighten5, // Added variable
      },
      dark: {
        primary: colors.blue.lighten3,
        // If using base color, be use to mark as such to get HEX value
        background: colors.indigo.base,
      },
    },
  },
});

new Vue({
  router,
  store,
  vuetify,
  render: (h) => h(App),
}).$mount('#app');

Мне кажется странным, что $ vuetify undefined, поскольку я пробовал нечто подобное с Vue.prototype.$socket.emit('my_event', { data: 'I\'m connected!' });, и это сработало.

В чем может быть ошибка?

...