Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nuke-input

Package Overview
Dependencies
Maintainers
3
Versions
185
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuke-input

输入框

  • 0.4.0
  • npm
  • Socket score

Version published
Weekly downloads
24
increased by118.18%
Maintainers
3
Weekly downloads
 
Created
Source

Input

  • category: UI
  • chinese: 带UI的输入框
  • type: UI组件

注意 此 Input 自带了一些UI样式,如果你希望自己封装样式,可以使用TextInput组件。

API

属性配置说明类型默认值
type类型,可选为enclosed(有边线)/inset(空白)stringenclosed
multiple是否为多行,不选则为单行boolfalse
state状态,可选为''/success/error/warningstring''
value当前的value 值string
disabled状态 设置文本域禁用状态booleanfalse
defaultValue初始化的value 值(非受控用法)string
onInput输入事件functionfalse
onFocusFocus事件functionfalse
onBlurBlur事件functionfalse
onChangechangefunction(value, e)
maxLength最大长度numberundefined
hasLimitHint是否显示最大长度的提示, 仅对multiple有效booleanfalse
htmlType键盘类型,可选 text url password tel date time emailstringtext
autoFocus自动获得焦点booleanfalse
focus 实例方法让input获得焦点function
blur 实例方法让input失去焦点function

关于 defaultValue 与 value (非受控与受控的差别)

  • defaultValue : 传入 value 默认值,用于 constructor 中计算使用,生命周期函数改变也不会再改变。
<Input defaultValue="羊绒大衣" onChange={(value,e)=>{console.log(value)}} />
  • value: 受控用法,会随着生命周期函数改变而改变。
<Input value={this.state.value} onChange={(value,e)=>{console.log(value)}}/>

实例方法 focusblur

    //在某些情况下需要让 myinput 强制失去焦点
    focus=(e)=>{
        this.refs.myinput.focus();
    }
    blur = (e)=>{
        this.refs.myinput.blur();
    }
    change=(value,e)=>{
        console.log(value);//强制失去焦点后,会触发 onCchange
    }
    render(){
        return (
            <View>
                <Input ref="myinput" onChange={this.change}/>
                <Button type="primary" onPress={this.focus}>点我让input获得焦点</Button>
                <Button type="primary" onPress={this.blur}>失去焦点,获取输入内容</Button>
            </View>
        )
    }

Keywords

FAQs

Package last updated on 24 May 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