Socket
Socket
Sign inDemoInstall

nuke-image

Package Overview
Dependencies
0
Maintainers
2
Versions
61
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nuke-image

图片


Version published
Weekly downloads
36
Maintainers
2
Install size
42.1 kB
Created
Weekly downloads
 

Readme

Source

Image

  • category: UI
  • chinese: 图片
  • type: UI 组件

设计思路

基础组件,用于展示图片。

** 注意,在 native 端,图片必须声明宽高, 或通过 flex:1 等方式具备宽高,才能绘制,否则无法展现。**

API

属性配置说明类型默认值
src新增,与 source api 含义相同string
style必须写宽高,或通过 flex:1 等能力具备宽高占位,否则无法渲染object
resizeMode组件尺寸和图片尺寸不成比例的时候如何调整图片的大小枚举类型,可选 contain cover stretchstretch
onLoad图片 onLoad 方法,其中 e.size 可返回图片真实宽高function(e)

src

  • 图片 url

    • 建议使用 https 协议。
    • 建议不要使用相对路径。
    • 开发阶段,您如果需要任意尺寸图片,可以使用 placeholder 占位符服务, 如:
<Image
  src="https://via.placeholder.com/350x150"
  style={{ width: 350, height: 150 }}
/>
  • resizeMode 释义
    • contain : 包含,在区域内图片完全展示,不拉伸,不裁剪
    • cover : 覆盖,覆盖整个区域,可能图片本身会被部分被挡住而不显示,等比缩放,可能会裁剪
    • stretch : 拉伸,拉伸图片以撑满整个区域

例:

<View style={{ width: 600, height: 400 }}>
  <Image
    style={{ flex: 1 }}
    src="https://gd2.alicdn.com/imgextra/i2/413996455/TB2tNcJbd0opuFjSZFxXXaDNVXa_!!413996455.jpg"
  />
</View>

其他

  • bug、建议联系 @翊晨
  • 钉钉交流群

Keywords

FAQs

Last updated on 26 Sep 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc