V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
pyyalt
V2EX  ›  React

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

  •  
  •   pyyalt · 2 天前 · 485 次点击

    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 来改变图片大小的。
    
    第 1 条附言  ·  2 天前
    没有 React 的大佬么?😊
    3 条回复    2025-11-06 14:44:27 +08:00
    Nyeshuai
        1
    Nyeshuai  
       1 天前   ❤️ 1
    react-native 本就不支持 className ,nativewind 默认只转换了内置的,第三方不支持很正常,不光 Image 。你需要 interop 一下,cssInterop(Image, { className: 'style' });
    pyyalt
        2
    pyyalt  
    OP
       1 天前
    @Nyeshuai 嗯呐。感谢回复,我看到 nativewind 也有类似的 issues 的问题。
    AgileLC
        3
    AgileLC  
       1 天前
    @Nyeshuai 学到了
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   2709 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 05:47 · PVG 13:47 · LAX 21:47 · JFK 00:47
    ♥ Do have faith in what you're doing.