vitejs / vite-plugin-vue2-jsx

Vite plugin for Vue 2.7 JSX support
MIT License
58 stars 6 forks source link

在.vue文件中编写jsx时出现编译错误 #6

Closed wwh0219 closed 2 years ago

wwh0219 commented 2 years ago

同样的jsx代码,在babel下正常编译运行,在vite中报错

Failed to parse source for import analysis because the content contains invalid JS syntax. Install @vitejs/plugin-vue to handle .vue files.

<script>
//App.vue
export default {
    render(){
        return <div>321</div>
   }
}
</script>
wwh0219 commented 2 years ago

通过在script标签上加上lang="jsx"解决

jetBn commented 1 year ago

有插件可以使用吗 ?

zhao-yi-fan commented 1 year ago

有没有不加lang的方式,因为引用第三方库有很多script上都没有加lang

i-ce-fish commented 11 months ago

有插件可以使用吗 ?

有 , vite-plugin-lang-jsx

https://juejin.cn/post/7249933985564000312#heading-8