jdf2e / nutui-react

京东风格的移动端 React 组件库 、支持多端小程序(A React UI Toolkit for Mobile Web)
https://nutui.jd.com/react/
919 stars 263 forks source link

微信小程序nutui-react-taro 2.6.16-2.6.20的Uploader组件,随机出现选择图片以及上传完成后不显示 #2622

Open fifthday opened 2 months ago

fifthday commented 2 months ago

NutUI React 包名

@nutui/nutui-react-taro

NutUI React 版本号

2.6.16

平台

weapp

重现链接

重现步骤

正常使用Uploader,autoUpload=true,单个图片模式

<Uploader
  uploadLabel={props.title}
  name={props.fileKey}
  url={Http.getUploadUrl()}
  data={{ order_id: props.orderId }}
  timeout={3e4}
  onStart={onStart}
  maxFileSize={maxFileSize}
  onOversize={onOversize}
  onFailure={onFailure}
  onSuccess={onSuccess}
/>

期望的结果是什么?

选择图后能正常预览

实际的结果是什么?

可以正常上传,但有时无法预览,选择以及上传成功后,预览处没有变化 试了更新到2.6.20还是一样

环境信息

👽 Taro v4.0.4

Taro CLI 4.0.4 environment info: System: OS: Windows 11 10.0.22631 Binaries: Node: 20.16.0 - D:\Scoop\apps\nvs\current\nodejs\default\node.EXE Yarn: 1.22.22 - D:\Scoop\apps\nvs\current\nodejs\default\yarn.CMD npm: 10.8.1 - D:\Scoop\apps\nvs\current\nodejs\default\npm.CMD npmPackages: @tarojs/cli: 4.0.4 => 4.0.4 @tarojs/components: 4.0.4 => 4.0.4 @tarojs/helper: 4.0.4 => 4.0.4 @tarojs/plugin-framework-react: 4.0.4 => 4.0.4 @tarojs/plugin-html: ^4.0.4 => 4.0.4 @tarojs/plugin-platform-alipay: 4.0.4 => 4.0.4 @tarojs/plugin-platform-h5: 4.0.4 => 4.0.4 @tarojs/plugin-platform-harmony-hybrid: 4.0.4 => 4.0.4 @tarojs/plugin-platform-jd: 4.0.4 => 4.0.4 @tarojs/plugin-platform-qq: 4.0.4 => 4.0.4 @tarojs/plugin-platform-swan: 4.0.4 => 4.0.4 @tarojs/plugin-platform-tt: 4.0.4 => 4.0.4 @tarojs/plugin-platform-weapp: 4.0.4 => 4.0.4 @tarojs/react: 4.0.4 => 4.0.4 @tarojs/runtime: 4.0.4 => 4.0.4 @tarojs/shared: 4.0.4 => 4.0.4 @tarojs/taro: 4.0.4 => 4.0.4 @tarojs/taro-loader: 4.0.4 => 4.0.4 @tarojs/webpack5-runner: 4.0.4 => 4.0.4 babel-preset-taro: 4.0.4 => 4.0.4 eslint-config-taro: 4.0.4 => 4.0.4 react: ^18.0.0 => 18.3.1

其他补充信息

我看了看源码分析如下:

src/packages/uploader/uploader.tsx文件中, image 这里useEffect是异步运行的,根据调用堆栈可知 image

image 多处有读取effect异步修改的fileListRef值然后重新设置,这里可能会导致fileList的值版本错误 我在使用时有时会发生选择图后,上传已经成功了,但是预览没变化,看不到图的情况 后来只好暂时用beforeXhrUpload,手动上传解决

Coder-Li commented 1 month ago

我也遇到这个问题了,这么明显的问题没想到还没修复

mrsquhuainan commented 4 days ago

我也一样