vuetifyjs / nuxt

Nuxt.js + Vuetify.js starter project template.
MIT License
306 stars 109 forks source link

Can't dynamically change theme from localStorage in created #79

Closed njzydark closed 5 years ago

njzydark commented 5 years ago

I want to save theme in localStorage and init theme in created,but it doesn't work. In spa mode,it work.

created() {
    if (process.browser) {
      this.initTheme()
    }
  },
  methods: {
    initTheme() {
      if (window.localStorage.defaultTheme) {
        var theme = JSON.parse(window.localStorage.defaultTheme)
      }
      this.defaultTheme = theme ? theme.base : colors.blue.base
      this.$vuetify.theme.primary = theme ? theme : colors.blue
    },
    handleThemeCheck(theme) {
      window.localStorage.defaultTheme = JSON.stringify(theme)
      this.defaultTheme = theme.base
      this.$vuetify.theme.primary = theme
    }
  }
GodLikeZeal commented 5 years ago

hello! I have a problem similar to yours. Could you tell me how to solve it? Thank you very much!

FlambeSk commented 5 years ago

Same issue here, some solutions?