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