Skip to content

Instantly share code, notes, and snippets.

@eliyas5044
Created May 16, 2021 16:07
Show Gist options
  • Save eliyas5044/9d730a98908767246125e8c36285555a to your computer and use it in GitHub Desktop.
Save eliyas5044/9d730a98908767246125e8c36285555a to your computer and use it in GitHub Desktop.
Fixing Nuxt client-side rendered virtual DOM error in vuetify
  1. Define isHydrated in data property and set default value false.
data: {
  return {
    isHydrated: false,
  };
},
  1. Define breakpoint computed property and set some default value of $vuetify breakpoints.
computed: {
  breakpoint() {
    return this.isHydrated
      ? this.$vuetify.breakpoint
      : { smAndUp: true, xsOnly: false };
  },
},
  1. Set isHydrated value true in mounted hook.
mounted() {
  this.isHydrated = true;
},
  1. Use breakpoint computed property instead of $vuetify.breakpoint in template.
<template>
  <v-app id="app">
    <v-navigation-drawer
      v-if="breakpoint.xsOnly"
      fixed
      app
    >
      <v-btn>My Profile</v-btn>
    </v-navigation-drawer>
  </v-app>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment