Failed to parse source for import analysis because the content contains invalid JS syntax

Vue3 在采用 compositionAPI 时候,Vite编译报错:

[vite] Internal server error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.

我遇到的报错原因是因为:

async setup(props) { // setup前面用async 异步关键字需注意阻塞风险
    
 
    await XXXX; // await后面 异步出现阻塞 导致报错 
}

最好直接用Vue3 script-setup 语法糖去写 Vue3 script-setup语法

posted @ 2021-10-01 20:02  天渺工作室  阅读(5395)  评论(0编辑  收藏  举报