vue 文件可以正常显示:
<image class="logo" src="/static/logo.png" />
tsx 文件无法正常显示:
import logo from '@/static/logo.png';
return () => (
<view>
<img src={logo}></img>
</view>)
vite.config.ts 配置:
import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import vueJsx from "@vitejs/plugin-vue-jsx";
import { resolve } from 'path'
export default defineConfig({
plugins: [uni(), vueJsx()],
resolve: {
alias: {
'@': resolve(__dirname, 'src') // 设置 @
指向 src
目录
}
},
});
2 个回复
云中千寻 (作者)
{
"name": "uni-preset-vue",
"version": "0.0.0",
"scripts": {
"dev:app": "uni -p app",
"dev:custom": "uni -p",
"dev:h5": "uni",
"dev:h5:ssr": "uni --ssr",
"dev:mp-alipay": "uni -p mp-alipay",
"dev:mp-baidu": "uni -p mp-baidu",
"dev:mp-kuaishou": "uni -p mp-kuaishou",
"dev:mp-lark": "uni -p mp-lark",
"dev:mp-qq": "uni -p mp-qq",
"dev:mp-toutiao": "uni -p mp-toutiao",
"dev:mp-weixin": "uni -p mp-weixin",
"dev:quickapp-webview": "uni -p quickapp-webview",
"dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei",
"dev:quickapp-webview-union": "uni -p quickapp-webview-union",
"build:app": "uni build -p app",
"build:custom": "uni build -p",
"build:h5": "uni build",
"build:h5:ssr": "uni build --ssr",
"build:mp-alipay": "uni build -p mp-alipay",
"build:mp-baidu": "uni build -p mp-baidu",
"build:mp-kuaishou": "uni build -p mp-kuaishou",
"build:mp-lark": "uni build -p mp-lark",
"build:mp-qq": "uni build -p mp-qq",
"build:mp-toutiao": "uni build -p mp-toutiao",
"build:mp-weixin": "uni build -p mp-weixin",
"build:quickapp-webview": "uni build -p quickapp-webview",
"build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
"build:quickapp-webview-union": "uni build -p quickapp-webview-union"
},
"dependencies": {
"@dcloudio/uni-app": "^3.0.0-alpha-3040120220308001",
"@dcloudio/uni-app-plus": "^3.0.0-alpha-3040120220308001",
"@dcloudio/uni-components": "^3.0.0-alpha-3040120220308001",
"@dcloudio/uni-h5": "^3.0.0-alpha-3040120220308001",
"@dcloudio/uni-mp-alipay": "^3.0.0-alpha-3040120220308001",
"@dcloudio/uni-mp-baidu": "^3.0.0-alpha-3040120220308001",
"@dcloudio/uni-mp-kuaishou": "^3.0.0-alpha-3040120220308001",
"@dcloudio/uni-mp-lark": "^3.0.0-alpha-3040120220308001",
"@dcloudio/uni-mp-qq": "^3.0.0-alpha-3040120220308001",
"@dcloudio/uni-mp-toutiao": "^3.0.0-alpha-3040120220308001",
"@dcloudio/uni-mp-weixin": "^3.0.0-alpha-3040120220308001",
"@dcloudio/uni-quickapp-webview": "^3.0.0-alpha-3040120220308001",
"vue": "^3.2.31",
"vue-i18n": "^9.1.9",
"vuex": "^4.0.2"
},
"devDependencies": {
"@dcloudio/types": "^2.5.17",
"@dcloudio/uni-automator": "^3.0.0-alpha-3040120220308001",
"@dcloudio/uni-cli-shared": "^3.0.0-alpha-3040120220308001",
"@dcloudio/vite-plugin-uni": "^3.0.0-alpha-3040120220308001",
"autoprefixer": "^10.4.2",
"typescript": "^4.6.2",
"vite": "^2.8.6"
}
}
q***@gmail.com
tsx跑起来了 ?我的好像都没编译,虽然没报错