问题
我在 Vue.js 3 中使用 async setup(),但我的 HTML 内容消失了。我的组件模板没有插入到 HTML,但是当我删除 async 和 await 前缀时,我的 HTML 内容又回来了。我怎样才能解决这个问题?
async setup () {
const data = ref(null)
try {
const res = await fetch('api')
data.value = res.json()
}
catch (e) {
console.error(e)
}
return {
data
}
}
Run Code Online (Sandbox Code Playgroud)
我试过了
<Suspense>标签,但仍然是同样的问题