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