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

react-pinyin-select-2

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-pinyin-select-2

React选择控件(支持拼音搜索)

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

React选择组件(支持拼音搜索)

本项目fork自react-select-pinyin,基于react-select开发。

相对于react-select,添加了以下特性:

  • 支持输入中文匹配(如 北, 京 会匹配北京市)
  • 支持输入全拼匹配(如 beijingshi, beijing, beij, b 会匹配北京市)
  • 支持输入首字母匹配(如 bjs, bj, b 会匹配北京市)
  • 支持非开始位置的匹配(如 jingshi, ijins, eij 会匹配北京市)
  • 不支持子串匹配(如 beishi 不会匹配北京市)

相对于react-select-pinyin,添加了以下特性:

  • 升级react到0.14
  • 纯函数组件
  • 使用ES2015语法
  • 更换拼音处理库为pinyinlite,更轻量、效率更佳、更适合浏览器使用

Live Demo

https://javascript-ninja.github.io/react-pinyin-select

安装

npm install react-pinyin-select-2 --save

使用方式

直接 requireimport 使用即可,具体的 api 和 react-select 一致:

import PinyinSelect from 'react-pinyin-select';

const options = [
  { value: '110100', label: '北京市' },
  { value: '120100', label: '天津市' }
];

function logChange(val, option) {
  console.log(val, option);
}

<PinyinSelect
  name="form-field-name"
  value="one"
  options={options}
  onChange={logChange}
/>

默认的 css 在 lib/default.css 中,如果你使用webpack之类的构建工具并配置了对应的loader,可以这样使用:

require ('react-pinyin-select/lib/default.css'); // CommonJS

import 'react-pinyin-select/lib/default.css'; // ES2015

否则请按照你项目中插入 css 的方式自行取用。

Keywords

FAQs

Package last updated on 12 Apr 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