You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

nuke-components

Package Overview
Dependencies
Maintainers
4
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuke-components

nuke原件库


Version published
Weekly downloads
69
increased by137.93%
Maintainers
4
Created
Weekly downloads
 

Readme

Source

deprecated component

Components

  • category: UI
  • chinese: 原件
  • type: UI 组件

View

View 是一个容器组件,类似于 web 端 div,它可以任意嵌套,但嵌套层数过深可能会导 致页面在安卓 5.0 以下或部分机型闪退。 View 有如下默认样式:

position: relative;
box-sizing: border-box;
display: flex;
flex-direction: column;

Text

Text 用于显示文本,类似于 web 端的 span 标签。 Text 标签不支持嵌套。

Image

API

属性配置说明类型默认值
source格式 {uri:"xxx"}object
style必须写宽高,否则无法渲染object
resizeMode组件尺寸和图片尺寸不成比例的时候如何调整图片的大小枚举类型,可选center contain cover stretchstretch
onLoad图片 onLoad 方法,其中 e.size 可返回图片真实宽高function(e)
  • resizeMode 释义 - contain : 包含,在区域内图片完全展示,不拉伸,不裁剪 - cover : 覆盖,覆盖整个区域,可能图片本身会被部分被挡住而不显示,等比缩放,可能会裁 剪 - stretch : 拉伸,拉伸图片以撑满整个区域 - center : 图片可能会被缩小以完全 展示,但如果图片过小不会放大

例:

<Image
  source={{
    uri:
      'https://gd2.alicdn.com/imgextra/i2/413996455/TB2tNcJbd0opuFjSZFxXXaDNVXa_!!413996455.jpg'
  }}
  style={{ quality: 'original', width: '100rem', height: '100rem' }}
  resizeMode={'cover'}
/>;

TextInput

TextInput 是唤起用户输入的基础组件。当定义 multiline 输入多行文字时其功能相当于 textarea。

它支持的属性有:

属性说明类型默认值
multiline【即将废弃】定义该属性文本框可以输入多行文字booleanfalse
multiple定义该属性文本框可以输入多行文字booleanfalse
accessibilityLabel为元素添加标识string
autoComplete添加开启自动完成功能booleanfalse//todo
autoFocus添加开启获取焦点booleanfalse
editable文本框是否可编辑booleantrue
keyboardType【即将废弃】设置弹出哪种软键盘 可用的值有default ascii-capable numbers-and-punctuation url number-pad phone-pad name-phone-pad email-address decimal-pad twitter web-search numericstringdefault
type设置弹出哪种软键盘 可用的值有text url password tel date time emailstringtext
maxLength设置最大可输入值number
maxNumberOfLines当文本框为 mutiline 时设置最多的行数number
numberOfLines同上设置行数number
placeholder设置文本框提示string
password【即将废弃】文本框内容密码显示
secureTextEntry【即将废弃】同上文本框内容密码显示
value文本框的文字内容string
style自定义样式Object

同时 TextInput 响应下面几个事件:

  • onBlur: 文本框失焦时调用此函数。onBlur={() => console.log(' 失焦啦 ')}
  • onFocus: 文本框获得焦点时调用此函数
  • onChange: 文本框内容变化时调用此函数
  • onInput: 文本框输入内容时调用此函数

使用示例:

<TextInput
  placeholder="Enter text to see events"
  autoFocus
  multiline
  onFocus={() => console.log('onFocus')}
  onBlur={() => console.log('onBlur')}
  onInput={() => console.log('onInput')}
  style={{
    width: '1000rem',
    height: '1000rem',
    borderWidth: '1rem',
    borderStyle: 'solid',
    borderColor: '#cccccc'
  }}
/>;

ScrollView

ScrollView 是一个包装了滚动操作的组件。一般情况下需要一个确定的高度来保证 ScrollView 的正常展现。

ScrollView

属性说明类型默认值
horizontal是否横向booleanfalse
scrollEventThrottle在滚动过程中,scroll 事件被调用的频率(默认值为 100),用于滚动的节流number100
showsHorizontalScrollIndicator是否显示水平滚动条booleantrue
showsVerticalScrollIndicator是否显示垂直滚动条booleantrue
onEndReachedThreshold设置加载更多的偏移string500rem
onEndReached滚动到底部时的事件(diff 为 onEndReachedThreshold)event

resetLoadmore 实例方法

由业务自行控制的是否触发 loadmore 事件

当 onEndReached 触发,但是数据没有变化或者数组变短,native 认为不需要再触发 onEndReached 事件了。

此时调用 resetLoadmore ,可以清除某个标记位,让 onEndReached 可以再次触发。

TouchableHighlight

TouchableHighlight 定义简单的 touch 事件。

属性说明类型默认值
onPress点击事件function(e)
activeStyle手指按下时的样式object

使用示例:

<TouchableHighlight
  onPress={() => {}}
  style={{
    backgroundColor: '#3089dc',
    height: '60rem',
    justifyContent: 'center',
    alignItems: 'center'
  }}
  activeStyle={{ backgroundColor: '#cccccc' }}
>
  Hello Nuke
</TouchableHighlight>;

Switch

Switch 是状态切换的开关按钮组件。

Switch

属性说明类型默认值
size尺寸,可选medium ,smallstringmedium
disabled开关是否可交互booleantrue
checked开关默认状态开启或关闭booleanfalse
onValueChange值改变时调用此函数event

Video

视频播放组件,在 h5 端即 html5 的 video 标签。

因此如果用在 h5 端,在部分安卓机型上,可能有较多兼容性问题。

属性说明类型默认值
autoPlay设置视频自动播放booleanfalse
src视频地址string

使用示例:

<Video autoPlay src="//path/to/url" />

Keywords

FAQs

Package last updated on 23 Nov 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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc