-
Notifications
You must be signed in to change notification settings - Fork 269
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
feat(image): support icon demo #2728
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,27 +13,27 @@ const Demo2 = () => { | |
<Image | ||
src={src} | ||
mode="aspectFit" | ||
width={pxTransform(80)} | ||
height={pxTransform(80)} | ||
radius={pxTransform(40)} | ||
width={80} | ||
height={80} | ||
radius={40} | ||
Comment on lines
+16
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 建议移除显式的宽度和高度设置 根据代码评审反馈,不建议在演示代码中直接指定图片的宽度和高度。建议将尺寸控制逻辑移至组件内部实现。 建议应用以下更改: - width={80}
- height={80}
- radius={40}
+ radius={40} Also applies to: 25-27, 34-36 |
||
/> | ||
</View> | ||
<View style={{ width: pxTransform(98) }}> | ||
<Image | ||
src={src} | ||
mode="scaleToFill" | ||
width={pxTransform(80)} | ||
height={pxTransform(80)} | ||
radius={pxTransform(40)} | ||
width={80} | ||
height={80} | ||
radius={40} | ||
/> | ||
</View> | ||
<View style={{ width: pxTransform(98) }}> | ||
<Image | ||
src={src} | ||
mode="scaleToFill" | ||
width={pxTransform(80)} | ||
height={pxTransform(80)} | ||
radius={pxTransform(10)} | ||
width={80} | ||
height={80} | ||
radius={10} | ||
/> | ||
</View> | ||
</View> | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8,8 +8,8 @@ const Demo5 = () => { | |||||||||
<> | ||||||||||
<Image | ||||||||||
src="http://m.360buyimg.com/babel/s181x181_jfs/t1/210178/19/10205/31538/619bbcd9E5071aed5/8e1b7eb632aeed49.png" | ||||||||||
width={pxTransform(30)} | ||||||||||
height={pxTransform(30)} | ||||||||||
width={30} | ||||||||||
height={30} | ||||||||||
Comment on lines
+11
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 建议保持响应式设计的一致性 代码中存在以下问题:
建议应用以下修改: - width={30}
- height={30}
+ width={pxTransform(30)}
+ height={pxTransform(30)} 另外,这个改动似乎没有解决 PR 中提到的 HarmonyOS 环境下 onError 事件的问题。是否需要添加相关的错误处理逻辑? 📝 Committable suggestion
Suggested change
|
||||||||||
/> | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 建议添加错误处理的演示用例 考虑到 PR 的主要目标是解决 HarmonyOS 环境下 onError 事件的问题,建议在 demo 中添加:
建议添加如下示例代码: <Image
- src="http://m.360buyimg.com/babel/s181x181_jfs/t1/210178/19/10205/31538/619bbcd9E5071aed5/8e1b7eb632aeed49.png"
+ src="invalid-image-url"
width={30}
height={30}
+ onError={(e) => {
+ console.log('Image load failed:', e)
+ }}
/>
|
||||||||||
<View | ||||||||||
style={{ | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -30,12 +30,7 @@ const Demo7 = () => { | |||||||||||||||||||||||||
}} | ||||||||||||||||||||||||||
key={mode} | ||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||
<Image | ||||||||||||||||||||||||||
src={src} | ||||||||||||||||||||||||||
mode={mode as any} | ||||||||||||||||||||||||||
width={pxTransform(80)} | ||||||||||||||||||||||||||
height={pxTransform(80)} | ||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||
<Image src={src} mode={mode as any} width={80} height={80} /> | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 建议统一使用 pxTransform 处理尺寸 当前实现中,外层 View 使用 pxTransform 处理尺寸,而 Image 组件直接使用固定数值,这样的处理方式不够统一。另外,根据评论建议,不需要为图片指定固定的宽高。 建议修改实现方式: -<Image src={src} mode={mode as any} width={80} height={80} />
+<Image
+ src={src}
+ mode={mode as any}
+ width={pxTransform(80)}
+ height={pxTransform(80)}
+/> 或者考虑完全移除固定尺寸,让图片自适应容器大小: -<Image src={src} mode={mode as any} width={80} height={80} />
+<Image src={src} mode={mode as any} /> 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
</View> | ||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||
})} | ||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
缺少错误处理演示
考虑到 PR 的主要目标是解决 HarmonyOS 环境下的 onError 事件问题,建议在该演示组件中添加错误处理的示例。
📝 Committable suggestion