关于vue3:Vite-because-the-content-contains-invalid-JS-syntax

11次阅读

共计 335 个字符,预计需要花费 1 分钟才能阅读完成。

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

正文完
 0