Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

react-picker-address

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-picker-address

react mobile address picker component

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
24
118.18%
Maintainers
1
Weekly downloads
 
Created
Source

react-picker-address

react 仿京东手机端地址选择组件.

NPM version gemnasium deps node version npm download

install

react-picker-address

Usage

import React from 'react';
import ReactDOM from 'react-dom';
import Picker from 'react-picker-address';
import 'react-picker-address/dist/react-picker-address.css';
import { district } from './district';

class PickerDemo extends React.Component {
  state = {
    visible: false,
    address: '',
  }

  showPicker = () => {
    this.setState({
      visible: true,
    });
  }

  hidePicker = () => {
    this.setState({
      visible: false,
    });
  }

  onChange = (value, selectedRows) => {
    this.setState({
      address: selectedRows.map(item => item.title).join(','),
      visible: false
    })
    console.log('选择值:', value);
  }

  render() {
    return (
      <div>
        <input onClick={this.showPicker} value={this.state.address} placeholder="请选择地区" readOnly />
        <Picker 
          visible={this.state.visible} 
          onClose={this.hidePicker} 
          dataSource={district} 
          onChange={this.onChange}
        />
      </div>
    );
  }
}

ReactDOM.render(<PickerDemo />, container);

API

props

nametypedefaultdescription
prefixClsStringpicker-address
titleString | node配送至标题
classNameString跟节点class
dataSourcearray数据源
onCloseFunction关闭时回调函数
onChangeFunction选择完闭时的回调函数; (value, selectedRows) => {}
tipTextstring请选择下一项的提示文字
valuearray初始值

Development

npm install
npm start

Keywords

react

FAQs

Package last updated on 04 Feb 2018

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