1 | # bee-switch
|
2 | [![npm version](https://img.shields.io/npm/v/bee-switch.svg)](https://www.npmjs.com/package/bee-switch)
|
3 | [![Build Status](https://img.shields.io/travis/tinper-bee/bee-switch/master.svg)](https://travis-ci.org/tinper-bee/bee-switch)
|
4 | [![Coverage Status](https://coveralls.io/repos/github/tinper-bee/bee-switch/badge.svg?branch=master)](https://coveralls.io/github/tinper-bee/bee-switch?branch=master)
|
5 |
|
6 | 两种状态切换的开关
|
7 |
|
8 |
|
9 |
|
10 | ## 使用
|
11 |
|
12 | ### 使用单独的switch包
|
13 | #### 组件引入
|
14 | 先进行下载switch包
|
15 | ```
|
16 | npm install --save bee-switch
|
17 | ```
|
18 | 组件调用
|
19 | ```js
|
20 | import { Switch } from 'bee-switch';
|
21 | React.render(<div>
|
22 | <Switch />
|
23 | </div>, document.getElementById('target'));
|
24 | ```
|
25 | #### 样式引入
|
26 |
|
27 | - 可以使用link引入dist目录下switch.css
|
28 | ```
|
29 | <link rel="stylesheet" href="./node_modules/build/bee-switch.css">
|
30 | ```
|
31 | - 可以在js中import样式
|
32 | ```js
|
33 | import "./node_modules/src/Switch.scss"
|
34 | //或是
|
35 | import "./node_modules/build/bee-switch.css"
|
36 | ```
|
37 |
|
38 |
|
39 |
|
40 | ## API
|
41 |
|
42 | |参数|说明|类型|默认值|
|
43 | |:---|:----|:---|:------|
|
44 | |checked |指定当前是否选中| Boolean |false|
|
45 | |defaultChecked |初始是否选中 |Boolean| false |
|
46 | |onChangeHandler |变化时回调函数,自定义参照demo |Function(checked:Boolean) |
|
47 | |checkedChildren |选中时的内容 |React| Node |
|
48 | |unCheckedChildren |非选中时的内容 |React| Node
|
49 | |size| 大小设置,oneOf:`primary`,`success`,`info`,`dark`,`warning`|string|''|
|
50 | |colors| 颜色设置,oneOf:`sm`, `lg`,''| string |''|
|
51 |
|
52 | #### setup develop environment
|
53 |
|
54 | ```sh
|
55 | $ git clone https://github.com/tinper-bee/bee-switch
|
56 | $ cd bee-switch
|
57 | $ npm install
|
58 | $ npm run dev
|
59 | ```
|