Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avatar组件设置lazy后fallback属性失效,不能在失败后显示图片 #5007

Closed
FeiFanLiang opened this issue Jun 30, 2023 · 2 comments · Fixed by #5026
Closed

avatar组件设置lazy后fallback属性失效,不能在失败后显示图片 #5007

FeiFanLiang opened this issue Jun 30, 2023 · 2 comments · Fixed by #5026
Labels
untriaged need to sort

Comments

@FeiFanLiang
Copy link

TuSimple/naive-ui version (版本)

2.34.4

Vue version (Vue 版本)

3.3.4

Browser and its version (浏览器及其版本)

chrome

System and its version (系统及其版本)

windows

Node version (Node 版本)

Reappearance link (重现链接)

https://www.naiveui.com/zh-CN/os-theme/components/avatar

Reappearance steps (重现步骤)

同时设置lazy属性和fallback后,图片加载失败不能正确显示fallback,onError回调也没有触发

Expected results (期望的结果)

在加载失败后,正确显示fallback

Actual results (实际的结果)

失败后,fallback失效

Remarks (补充说明)

image
image

@github-actions github-actions bot added the untriaged need to sort label Jun 30, 2023
@jahnli
Copy link
Collaborator

jahnli commented Jun 30, 2023

  • 关于 on-error 源码中是这样设计的,需要确定具体用意
const shouldStartLoadingRef = ref(!props.lazy)

const handleError = (e: Event): void => {
    if (!shouldStartLoadingRef.value) return
}

@FeiFanLiang
Copy link
Author

那设置的fallback也无效,使用lazy属性后,没办法进行fallback吗?

jizai1125 added a commit to jizai1125/naive-ui that referenced this issue Jul 5, 2023
07akioni added a commit that referenced this issue Dec 21, 2023
…ad error in lazy (#5026)

* fix(avatar): lazy loading and `fallback-src` prop not working  when load error in lazy, closes #5007

* Update src/avatar/src/Avatar.tsx

---------

Co-authored-by: 07akioni <07akioni2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged need to sort
Projects
None yet
2 participants