# vue项目里使用tsx
- 1 安装 npm i @vitejs/plugin-vue-jsx --S
- 2 vite.config.ts
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(), vueJsx()],
});
1
2
3
4
5
6
7
2
3
4
5
6
7
tsx模版
import { defineComponent, reactive } from "vue";
import { dxget, qurl } from "../../util/index";
export default defineComponent({
props: {
code: {
type: String,
},
},
emits: ['click'],
setup(props,context) {
// context.emit('click','text'); 向父组件传值
return () => (
<>
<div>{props.code}</div>
</>
);
},
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
← vuex vite.config →