From 7618b687139ee137ab1c1fadfa427af18115e687 Mon Sep 17 00:00:00 2001 From: bob <312777916@qq.com> Date: Mon, 12 May 2025 21:12:12 +0800 Subject: [PATCH] =?UTF-8?q?jxp=E5=8A=A8=E6=80=81=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.cjs | 8 ++++++-- jsconfig.json | 3 +++ package.json | 2 ++ vite.config.js | 10 +++++++++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 155ba81..6451c9d 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -9,7 +9,10 @@ module.exports = { '@vue/eslint-config-prettier/skip-formatting' ], parserOptions: { - ecmaVersion: 'latest' + ecmaVersion: 'latest', + ecmaFeatures: { + jsx: true + } }, rules: { 'prettier/prettier': [ @@ -27,6 +30,7 @@ module.exports = { { ignores: ['index'] // vue组件名称多单词组成(忽略index.vue) } - ] + ], + 'vue/jsx-uses-vars': 'error' // 确保 JSX 中使用的变量被正确识别 } } diff --git a/jsconfig.json b/jsconfig.json index 5a1f2d2..8d93064 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,5 +1,8 @@ { "compilerOptions": { + "jsx": "preserve", + "jsxFactory": "h", + "jsxFragmentFactory": "Fragment", "paths": { "@/*": ["./src/*"] } diff --git a/package.json b/package.json index 7b9ab5e..2b61143 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,9 @@ "devDependencies": { "@rushstack/eslint-patch": "^1.8.0", "@vitejs/plugin-vue": "^5.0.5", + "@vitejs/plugin-vue-jsx": "^4.1.2", "@vue/eslint-config-prettier": "^9.0.0", + "@vue/runtime-dom": "^3.5.13", "eslint": "^8.57.0", "eslint-plugin-vue": "^9.23.0", "husky": "^8.0.0", diff --git a/vite.config.js b/vite.config.js index c3d4a80..49f57d4 100644 --- a/vite.config.js +++ b/vite.config.js @@ -2,11 +2,19 @@ import { fileURLToPath, URL } from 'node:url' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx' import svgLoader from 'vite-svg-loader' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [vue(), svgLoader()], + plugins: [ + vue(), + vueJsx({ + transformOn: true, + optimize: true + }), + svgLoader() + ], base: '/im', resolve: { alias: {