未在Referh上定义错误localStorageNuxt Js,解析服务器

问题描述

enter image description here

在刷新页面时遇到上述错误,但我未在代码中使用localStorage。

解决方法

只能在以下if语句中的浏览器中执行操作:

if (process.client) {
localStorage...
}

请参阅:https://nuxtjs.org/api/context/

另一种选择是仅在beforeMountmounted函数中调用它,因为它们总是发生在客户端。