4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Nuxt3 Hydration node mismatch

Last updated at Posted at 2021-12-02

Hydration node mismatch

サーバサイドとクライアントサイドでrenderした時の差異がある場合上記のerrorが出る気がする

下記のコードとか出そうな気がする

<template>
  <div v-if="show">
    hoge
  </div>
</template>

<script setup lang="ts">
const show = computed(() => { return document===undefined})
</script>

この場合 Mount後に書き出せば問題ないの気がするのでで以下のようにすればいい気もする

<template>
  <div v-if="show">
    hoge
  </div>
</template>

<script setup lang="ts">
const show = ref(true)
onMounted(
  () = > {show.value = computed(() => { return document===undefined})}
)
</script>

参考

https://www.digitalocean.com/community/tutorials/vuejs-component-lifecycle-ja

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?