V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
pyyalt
0.03D
0.02D
V2EX  ›  React

expo-image 在使用时候必须要加 style 属性 ?

  •  
  •   pyyalt · Nov 6, 2025 · 2059 views
    This topic created in 173 days ago, the information mentioned may be changed or developed.

    import { Image as ImageNative } from 'expo-image';

    <ImageNative source={imageUri} placeholder={{ blurhash }} className="w-full h-48 rounded-lg mb-2" style={{ height:192,width:100% }} contentFit="cover" transition={200}/>

         实际测试好像必须加 style 图片才会正确显示。那么如果有很多地方使用,每次加 style 不是很麻烦嘛? 我是想直接使用 className 来改变图片大小的。
    
    Supplement 1  ·  Nov 6, 2025
    没有 React 的大佬么?😊
    3 replies    2025-11-06 14:44:27 +08:00
    Nyeshuai
        1
    Nyeshuai  
       Nov 6, 2025   ❤️ 1
    react-native 本就不支持 className ,nativewind 默认只转换了内置的,第三方不支持很正常,不光 Image 。你需要 interop 一下,cssInterop(Image, { className: 'style' });
    pyyalt
        2
    pyyalt  
    OP
       Nov 6, 2025
    @Nyeshuai 嗯呐。感谢回复,我看到 nativewind 也有类似的 issues 的问题。
    AgileLC
        3
    AgileLC  
       Nov 6, 2025
    @Nyeshuai 学到了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3739 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 04:30 · PVG 12:30 · LAX 21:30 · JFK 00:30
    ♥ Do have faith in what you're doing.