Socket
Socket
Sign inDemoInstall

nuke-image

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuke-image

图片


Version published
Maintainers
1
Created
Source

Image

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

设计思路

在 native 端对 image 标签封装,在 web 端使用 img 完成适配。

** 注意,在 native 端,图片必须声明宽高才能绘制,否则无法展现。**

API

属性配置说明类型默认值
source格式 {uri:"xxx"}object
srcurl stringstring
style必须写宽高,否则无法渲染object
resizeMode组件尺寸和图片尺寸不成比例的时候如何调整图片的大小枚举类型,可选 contain cover stretchstretch
onLoad图片 onLoad 方法,其中 e.size 可返回图片真实宽高function(e)
quality是否无损,凡是 alicdn 的图片地址,默认开启压缩,如果 quality 设置为 original,则不压缩图片function(e)
  • 图片 url

    • 建议使用 https 协议。
    • 建议不要使用相对路径。
    • 开发阶段,您如果需要任意尺寸图片,可以使用 placeholder 占位符服务, 如:
     <Image source={{uri:"https://via.placeholder.com/350x150"}} style={{width:350,height:150}} quality="original"/>
    
  • resizeMode 释义

    • contain : 包含,在区域内图片完全展示,不拉伸,不裁剪
    • cover : 覆盖,覆盖整个区域,可能图片本身会被部分被挡住而不显示,等比缩放,可能会裁剪
    • stretch : 拉伸,拉伸图片以撑满整个区域

例:


    <Image source={{uri:"https://gd2.alicdn.com/imgextra/i2/413996455/TB2tNcJbd0opuFjSZFxXXaDNVXa_!!413996455.jpg"}} quality ="original"/>

Keywords

FAQs

Package last updated on 01 Aug 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc