Snippets Collections
  mounted() {
    const theme = localStorage.getItem('useDarkTheme');
    if (theme) {
      if (theme == 'true') {
        setTimeout(() => {
          this.$vuetify.theme.dark = true;
        }, 0);
      } else {
        setTimeout(() => {
          this.$vuetify.theme.dark = false;
        }, 0);
      }
    } else if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
      setTimeout(() => {
        this.$vuetify.theme.dark = true;
      }, 0);
    }
  }
import createPersistedState from 'vuex-persistedstate'

export default ({ store }) => {
  createPersistedState()(store)
}
star

Thu Jul 22 2021 18:57:57 GMT+0000 (UTC) https://github.com/robinvdvleuten/vuex-persistedstate

#javascript #vue.js #nuxt

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension