Skip to content

Commit

Permalink
feature: 添加tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
jsxiaosi committed Dec 30, 2021
1 parent f9ea319 commit 8dfb20a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion build/vite/plugin/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import vue from '@vitejs/plugin-vue'

import vueJsx from '@vitejs/plugin-vue-jsx'

import type { Plugin, ConfigEnv } from 'vite'

// 按需加载样式配置
Expand All @@ -16,7 +18,7 @@ import { configMockPlugin } from './mock'
// import { configEsLinterPlugin } from './eslinter'

export function createVitePlugins(isBuild = false, _configEnv: ConfigEnv) {
const vitePlugins: (Plugin | Plugin[])[] = [vue()]
const vitePlugins: (Plugin | Plugin[])[] = [vue(), vueJsx()]
vitePlugins.push(configStylePlugin())

vitePlugins.push(configThemePlugin())
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
"@vitejs/plugin-vue": "^2.0.1",
"@vitejs/plugin-vue-jsx": "^1.3.3",
"@vue/compiler-sfc": "^3.2.26",
"@zougt/vite-plugin-theme-preprocessor": "^1.4.0",
"autoprefixer": "^10.4.0",
Expand Down
14 changes: 14 additions & 0 deletions src/components/tscomponents.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineComponent, ref } from 'vue'

export default defineComponent({
name: 'TsComponents',
setup(props) {
console.log(props)
const dataname = ref<string>('admin')
return () => (
<>
<div>{dataname.value}</div>
</>
)
},
})
2 changes: 1 addition & 1 deletion src/utils/mainConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ export const getServerConfig = (): Promise<string> => {
return new Promise((resolve) => {
setTimeout(() => {
resolve('')
}, 1000)
}, 0)
})
}
2 changes: 2 additions & 0 deletions src/views/useradmin/userlist/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div class="page-container">
<span>听说这个是用户列表</span>
<TsComponents />
<!-- <el-icon><iEL-baseball /></el-icon>
<SvgIcon name="daosanjiao"></SvgIcon>
{{ t('login.title') }}
Expand All @@ -14,6 +15,7 @@
</template>

<script setup lang="ts">
import TsComponents from '@/components/tscomponents.tsx'
// import SvgIcon from '@/components/SvgIcon/index.vue'
// import { getCurrentInstance } from 'vue'
Expand Down

0 comments on commit 8dfb20a

Please sign in to comment.