我建项目的时候,也出现了这问题.
DCloud_UNI_JBB 让我把插件版本降到3.1.0
npm install @vitejs/plugin-vue-jsx@3.1.0 --save-dev
如果是 vue 文件的组件,记得标签加上lang="jsx"
<script lang="jsx">
export default {
render(h) {
return <p>123</p>
}
}
</script>
下面是DCloud_UNI_JBB提供的 jsx 文件示例:
// HelloWorld.jsx
import { defineComponent, ref } from 'vue';
export default defineComponent({
name: 'HelloWorld',
setup() {
const count = ref(0);
const increment = () => {
count.value++;
};
return () => (
<div>
<h1>Hello JSX!</h1>
<p>计数: {count.value}</p>
<button onClick={increment}>点击+1</button>
</div>
);
}
});