Snippets Collections
//Inside a plugins folder

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.directive("click-outside", {
    beforeMount(el, binding) {
      el.clickOutsideEvent = function (event) {
        if (!(el === event.target || el.contains(event.target))) {
          binding.value(event, el);
        }
      };
      document.addEventListener("click", el.clickOutsideEvent);
    },
    unmounted(el) {
      document.removeEventListener("click", el.clickOutsideEvent);
    },
  });
});

//Inside the DOM
v-click-outside="handleCloseDestinationSearchResults"
object-fit: fill;
object-fit: contain;
object-fit: cover;
object-fit: none;
object-fit: scale-down;
  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

Mon Apr 08 2024 07:51:30 GMT+0000 (Coordinated Universal Time)

#js #nuxt
star

Fri Oct 20 2023 09:01:47 GMT+0000 (Coordinated Universal Time)

#nuxt
star

Thu Jul 22 2021 18:57:57 GMT+0000 (Coordinated Universal Time) 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