🎈 perf(完成优化):
This commit is contained in:
@@ -19,7 +19,7 @@ type Param = {
|
||||
name?: string
|
||||
}
|
||||
export default memo(({ value, onClick, showStatus = false, round = false, name = '' }: Param) => {
|
||||
const [imgs, setImgs] = useState<string[]>([])
|
||||
const [imgs, setImgs] = useState<string>('')
|
||||
|
||||
//lab是否都是0
|
||||
const rgbStyle = useMemo(() => {
|
||||
@@ -35,7 +35,7 @@ export default memo(({ value, onClick, showStatus = false, round = false, name =
|
||||
let imgs = value.texture_url.split(',').map((item) => {
|
||||
return formatImgUrl(item)
|
||||
})
|
||||
setImgs(() => imgs)
|
||||
setImgs(() => imgs[0])
|
||||
}
|
||||
}, [value])
|
||||
|
||||
@@ -50,10 +50,21 @@ export default memo(({ value, onClick, showStatus = false, round = false, name =
|
||||
setLabAndImgShow(true)
|
||||
}
|
||||
|
||||
const checkLoad = (val) => {
|
||||
setImgs(() => formatImgUrl(''))
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className={styles.labAndImg_main} style={{ borderRadius: round ? '50%' : '' }} onClick={() => onShowLabAndImg()}>
|
||||
{value.texture_url && <Image mode='aspectFill' src={imgs[0]} className={styles.labAndImg_image} style={{ borderRadius: round ? '50%' : '' }}></Image>}
|
||||
{value.texture_url && (
|
||||
<Image
|
||||
mode='aspectFill'
|
||||
src={imgs}
|
||||
onError={(e) => checkLoad(e)}
|
||||
className={styles.labAndImg_image}
|
||||
style={{ borderRadius: round ? '50%' : '' }}></Image>
|
||||
)}
|
||||
{!value.texture_url && rgbStyle && <View className={styles.boxColor} style={{ ...rgbStyle, borderRadius: round ? '50%' : '' }}></View>}
|
||||
{!value.texture_url && !rgbStyle && (
|
||||
<Image mode='aspectFill' src={formatImgUrl('')} className={styles.labAndImg_image} style={{ borderRadius: round ? '50%' : '' }}></Image>
|
||||
|
||||
Reference in New Issue
Block a user