React 选择控件(支持拼音搜索)
JedWatson 的 react-select 挺好用,但是不支持拼音搜索。
react-select-pinyin 基于 react-select 开发,添加了如下特性:
http://xcatliu.github.io/react-select-pinyin/
若你的项目是基于 CommonJS 风格的,则直接 require
使用即可,具体的 api 和 react-select 一样:
var Select = require('react-select-pinyin');
var options = [
{ value: '110100', label: '北京市' },
{ value: '120100', label: '天津市' }
];
function logChange(val) {
console.log("选择了: " + val);
}
<Select
name="form-field-name"
value="one"
options={options}
onChange={logChange}
/>
默认的 css 在 lib/default.css
中,请按照你项目中插入 css 的方式自行取用。
暂不支持
script
标签中引入暂不支持
更多使用方式请参考:react-select#usage
clone 之后,进入本项目,执行:
npm install
npm start
打开 http://localhost:8000 查看示例。
编辑 src
和 example
进行开发。
npm run lint
执行 eslint 检查npm run prepublish
将 src
中的 jsx
编译成 lib
中的 js
,并且会复制 react-select
中的 css 到 lib
npm version [<newversion> | major | minor | patch | prerelease | preminor | premajor ]
升级版本号git push && git push --tags
提交到 GitHub
npm publish
发布到 npmjs.com
npm run gh-pages
更新 gh-pages
分支