云中千寻
云中千寻
  • 发布:2022-03-11 19:47
  • 更新:2022-11-14 00:41
  • 阅读:725

【报Bug】tsx 在APP 端无法加载本地图片

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

HBuilderX类型: 正式

HBuilderX版本号: 3.4.0

手机系统: Android

手机系统版本号: Android 12

手机厂商: 华为

手机机型: 华为 p40 pro

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

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 目录
}
},
});

操作步骤:

新建一个项目测试即可

预期结果:

tsx 文件中的本地图片正常显示

实际结果:

tsx 文件中的本地图片无法正常显示

bug描述:

图片本地文件存在,同一个项目下 tsx 文件中的图片无法在 APP 端显示(H5 显示正常)

2022-03-11 19:47 负责人:无 分享
已邀请:
云中千寻

云中千寻 (作者)

{
"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

q***@gmail.com

tsx跑起来了 ?我的好像都没编译,虽然没报错

该问题目前已经被锁定, 无法添加新回复