1.0.5 • Published 4 years ago
@jswork/react-ant-select v1.0.5
react-ant-select
React ant select builder.
installation
npm install -S @jswork/react-ant-select
properties
Name | Type | Required | Default | Description |
---|---|---|---|---|
className | string | false | - | The extended className for component. |
value | any | false | - | Default value. |
placeholder | string | false | '请选择' | Placeholder. |
items | array | false | [] | The data source. |
template | func | false | RctplAntSelect | The data item template. |
onChange | func | false | noop | The change handler. |
usage
import css
@import "~@jswork/react-ant-select/dist/style.css"; // or use sass @import "~@jswork/react-ant-select/dist/style.scss"; // customize your styles: $react-ant-select-options: ()
import js
import ReactDemokit from '@jswork/react-demokit'; import React from 'react'; import ReactDOM from 'react-dom'; import ReactAntSelect from '@jswork/react-ant-select'; import Tpl1 from '@jswork/rctpl-ant-select-default'; import './assets/style.scss'; class App extends React.Component { state = { items2: ['001', '002', '003'], items: [ { value: 'op1', label: 'option1d' }, { value: 'op2', label: 'option2d' }, { value: 'op3', label: 'option3d' } ] }; handleChange = (inEvent) => { console.log('value:', inEvent.target.value); }; render() { const { items, items2 } = this.state; return ( <ReactDemokit className="p-3 app-container" url="https://github.com/afeiship/react-ant-select"> <h1>Has value:</h1> <ReactAntSelect template={Tpl1} items={items} onChange={this.handleChange} /> <ReactAntSelect template={Tpl1} items={items2} onChange={this.handleChange} /> <h1>Select is empty</h1> <ReactAntSelect items={[]} onChange={this.handleChange} /> </ReactDemokit> ); } } ReactDOM.render(<App />, document.getElementById('app'));
tempalte migrate
import ReactAntSelect from '@jswork/react-ant-select';
import RctplAntSelectDefault from '@jswork/rctpl-ant-select-default';
Object.assign(
ReactAntSelect.defaultProps,
{ template: RctplAntSelectDefault }
);
documentation
license
Code released under the MIT license.