You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<template><divclass="">home</div><ul><liv-for="(item, index) in list" :key="index">
id:{{ item.id }}, User : {{ item.userId }} , Title : {{ item.title }}
</li></ul></template>
/src/stores/todo.ts
import{acceptHMRUpdate,defineStore}from'pinia'interfaceListItem{id: number|null|string;userId: number|null|string;title: string|null;}interfaceTodoStore{list: ListItem[];title: string;}exportconstuseTodoStore=defineStore({id: 'todoStore',state: (): TodoStore=>({list: [],// By fetching the datatitle: 'Todo Page'// Data written directly}),getters: {getList(): ListItem[]{returnthis.list;},},actions: {setList(data: ListItem[]){this.list=data;console.log('Initialize list ...');},},});if(import.meta.hot)import.meta.hot.accept(acceptHMRUpdate(useTodoStore,import.meta.hot));
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
(Translation)🤭
Recently, I'm having some problems with Initial State,When the ssg generates the page, the data requested by axios is never initialized.
Am I doing something wrong?
Here's a simple example, State management uses pinia.
Reproduction link:https://stackblitz.com/edit/vitejs-vite-wafscg?file=src/pages/index.vue
最近在使用vite-ssg插件的初始化数据功能,遇到一些瓶颈。
不知道是哪里写的不对
在ssg生成页面的时候,始终没有初始化axios请求过来的数据。
以下是我写的一个简单的小例子。状态管理用的是pinia。
线上地址:https://stackblitz.com/edit/vitejs-vite-wafscg?file=src/pages/index.vue
/src/pages/index.vue
/src/stores/todo.ts
/src/modules/pinia.ts
The generated page
Beta Was this translation helpful? Give feedback.
All reactions