微信小程序中image组件转成taro,再转h5图片无法加载,需要在转成taro工程后,在图片路径上加require才会正常打包

jfgube3f  于 1个月前  发布在  其他
关注(0)|答案(3)|浏览(30)

相关平台

微信小程序

小程序基础库: 2.19.4
使用框架: React

复现步骤

1、新建微信小程序,使用image组件
2、在js文件中定义文件路径,在wxml中的image组件的src中引用图片路径
3、微信小程序转换为taro
4、trao转换为h5

期望结果

转成h5后,图片加载正常

实际结果

转成h5后,图片加载异常

环境信息

$ taro info
👽 Taro v3.6.6
Taro CLI 3.6.6 environment info:
    System:
      OS: Windows 10 10.0.19045
    Binaries:
      Node: 16.19.1 - D:\software\DevEco\nodeJs16\node.EXE
      npm: 8.19.3 - D:\software\DevEco\nodeJs16\npm.CMD
    npmPackages:
      @tarojs/cli: 3.6.6 => 3.6.6
      @tarojs/components: 3.6.6 => 3.6.6
      @tarojs/helper: 3.6.6 => 3.6.6
      @tarojs/plugin-framework-react: 3.6.6 => 3.6.6
      @tarojs/plugin-platform-alipay: 3.6.6 => 3.6.6
      @tarojs/plugin-platform-h5: 3.6.6 => 3.6.6
      @tarojs/plugin-platform-jd: 3.6.6 => 3.6.6
      @tarojs/plugin-platform-qq: 3.6.6 => 3.6.6
      @tarojs/plugin-platform-swan: 3.6.6 => 3.6.6
      @tarojs/plugin-platform-tt: 3.6.6 => 3.6.6
      @tarojs/plugin-platform-weapp: 3.6.6 => 3.6.6
      @tarojs/react: 3.6.6 => 3.6.6
      @tarojs/runtime: 3.6.6 => 3.6.6
      @tarojs/shared: 3.6.6 => 3.6.6
      @tarojs/taro: 3.6.6 => 3.6.6
      @tarojs/webpack5-runner: 3.6.6 => 3.6.6
      babel-preset-taro: 3.6.6 => 3.6.6
      eslint-config-taro: 3.6.6 => 3.6.6
      react: ^18.0.0 => 18.2.0
iecba09b

iecba09b2#

在taro工程中手动改成这种,再转换成h5后,预览正常

dfty9e19

dfty9e193#

转换代码需要修改下。

相关问题