-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
fix(rn): 修复previewImage 预览图片API的current必须是urls其中的一个 #11632
base: 3.x
Are you sure you want to change the base?
Changes from 3 commits
59639fe
34088cc
c00c1e7
d34770c
50d7845
c05caab
7e872cb
c668232
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 |
---|---|---|
|
@@ -25,9 +25,12 @@ export function previewImage(obj: Taro.previewImage.Option): void { | |
fail, | ||
complete | ||
}: any = obj || {} | ||
const index = urls.indexOf(current) | ||
if (index === -1) { | ||
|
||
let index = 0 | ||
if (urls.length === 0) { | ||
throw new Error('"current" or "urls" is invalid') | ||
} else { | ||
index = Math.max(current, urls.indexOf(current)) | ||
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. 这里的 urls.indexOf(current) 可以先声明出来,然后 === -1 时给个 warning 信息(console.warn('xxxx xxxx xxxx')),不等于 -1 时再取 max。 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. 突然发现不能取max,因为curreny是一个字符串,取max是返回的NaN let index = 0
if (!urls || urls.length === 0) {
throw new Error('待预览的图片列表"urls"不能为空')
} else {
urls.indexOf(current) === -1 ? console.warn('显示的图片不在预览列表当中') : ''
index = Math.max(0, urls.indexOf(current))
} 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.
const _index = urls.indexOf(current)
if (_index === -1) {
console.warn('xxxx')
}
index = Math.max(0, _index) |
||
} | ||
|
||
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. 修改后把 commit 合并成一个就行了 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. 这个我们 squash and merge 就会是一个commit 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. 哦哦 我以为要先合并呢😂 |
||
let sibling | ||
|
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.
这里把提示文案给改下吧