Quasar SSR水化与localStorage问题

问题描述

在localStorage中,有一个“ cookies”键,其中1为true,0为false,以确定用户是否已接受cookie策略(通知弹出窗口)。用户必须接受该策略,弹出窗口才会消失。

但是,当我在SSR模式下运行quasar应用程序时,渲染后会出现水化错误

  import { LocalStorage } from 'quasar'

  export default {

    data () {
      return {
        cookiesAccepted: Boolean(LocalStorage.getItem('cookiesAccepted'))
      }
    },// rest of the code

在组件的模板标签中,我有以下代码

      <template v-if="!cookiesAccepted">
        Cookies here
      </template>
    </q-layout>
  </template>

在SPA模式下,它可以正常工作,页面上未显示cookie消息,而在SSR模式下,它在页面上闪烁,并且出现此错误

enter image description here

有什么问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)