-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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): add test #349
Conversation
其实我仔细思考了一波,要不然把 alt 换成 image-props? 然后把这个 imageProps 在 |
好的老哥 |
PropType 类型可以用这个
在这个 PR 改就行 |
👌 |
Codecov Report
@@ Coverage Diff @@
## main #349 +/- ##
==========================================
+ Coverage 33.86% 34.29% +0.43%
==========================================
Files 507 507
Lines 12099 12106 +7
Branches 3304 3310 +6
==========================================
+ Hits 4097 4152 +55
+ Misses 7215 7158 -57
- Partials 787 796 +9
Continue to review full report at Codecov.
|
src/image/src/Image.tsx
Outdated
@@ -20,14 +29,24 @@ export default defineComponent({ | |||
props: imageProps, | |||
setup (props) { | |||
const imageRef = ref<HTMLImageElement | null>(null) | |||
const imgPropsRef = props.imgProps || {} |
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.
这么些不行,如果一开始没有后来有了就出错了
imgPropsRef = toRef(props, 'imgProps')
src/image/src/Image.tsx
Outdated
props.height ? props.height : imgPropsRef.height | ||
), | ||
mergedSrc: computed(() => (props.src ? props.src : imgPropsRef.src)), | ||
mergedAlt: computed(() => (props.alt ? props.alt : imgPropsRef.alt)), |
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.
38-45重复逻辑能否抽出一个函数来处理
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.
这一堆能不能用
pickImgKeys = [src,alt,height,width]
mergeProps(imgPropsRef.value,pickImgKeys.reduce(....))
来完成? @07akioni
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.
理论上是没问题的,不过这搞感觉也不会简单,我是感觉直接在 render 函数里合并就行了,不用造 computed
先用普通的 object 吧 |
No description provided.