klren0312 / daliy_knowledge

知识积累,正确使用方式是watch
21 stars 4 forks source link

nuxt3 刷新页面时,useFetch无法请求到数据 #846

Open klren0312 opened 4 weeks ago

klren0312 commented 4 weeks ago

需要在请求前加await nextTick()

export async function GetSoftwareListApi (): Promise<Software> {
  await nextTick()
  const res = await useFetch('http://127.0.0.1:4523/m1/5346725-0-default/getAppList', {
    key: genUUID()
  })
  return unref(res.data) as Software
}