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语法


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM