Subscribe on changes!

vue单文件组件在<script setup></script>中使用await报错

avatar
Jan 16th 2022

Version

3.2.26

Reproduction link

sfc.vuejs.org/

Steps to reproduce

vite+vue3项目单文件组件中使用await

What is expected?

await调用异步函数

What is actually happening?

报错


截图 截图 截图

avatar
Jan 16th 2022

You need to use Suspense in the parent component. In other words, move the code you have in App.vue to a another vue file, import that component in App.vue and use it like

<Suspens><MyComp/></Suspense>

Please, next time consider using the forum, the Discord server or StackOverflow for questions first. But feel free to come back and open an issue if it turns out to be a bug 🙂