When the async keyword is used to declare the setup function, the template will not be rendered
Version
3.0.11
Reproduction link
https://codesandbox.io/s/vue-async-setup-6flz8
Steps to reproduce
1、Create two reference components: <CustomCompA />
, <CustomCompB />
2、Use keyword async for setup in <CustomCompA />
, whereas async is not used in <CustomCompB />
The only difference between these two components is whether async setup
is set
What is expected?
<CustomCompA />
can be rendered normally.
What is actually happening?
<CustomCompA />
is not rendered.
Personal guess is the problem caused by async keyword. I’m not sure if this is a bug or my usage is wrong. The async I understand will not affect the execution of the function.
Yes, you are using the wrong way, async setup
can only be used in SSR, or must be used in CSR with the Suspense
component, see https://codesandbox.io/s/vue-async-setup-forked-31tyl. You are not the only one who has encountered similar confusion, I think we can improve the error report.
Yes, you are using the wrong way,
async setup
can only be used in SSR, or must be used in CSR with theSuspense
component, see https://codesandbox.io/s/vue-async-setup-forked-31tyl. You are not the only one who has encountered similar confusion, I think we can improve the error report.
Thanks! @HcySunYang , You are right. The Suspense
can solve the problem. I think it is necessary to indicate the special usage scenarios of setup in the document, such as async setup
, so as to prevent anyone from encountering the same problem.