浏览代码

INFO: hydrate store for ssr app

master
valere 5 个月前
父节点
当前提交
51921c9213
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. +1
    -1
      stores/comment.ts

+ 1
- 1
stores/comment.ts 查看文件

@@ -5,7 +5,7 @@ export const useCommentStore = defineStore('comment', {
state: () => ({
comment: useLocalStorage('comment', [])
}),
hydrate(state, initialState) {
hydrate(state, initialState) { // as nuxt is in SSR localstorage is not available so we need to hydrate the app with data first
state.comment = useLocalStorage('comment', [])
},
actions: {


正在加载...
取消
保存