[Improvement] Radio: name support any types (#863)

This commit is contained in:
neverland
2018-04-12 15:45:28 +08:00
committed by GitHub
parent ec47c8d0d3
commit 7c84582d7b
9 changed files with 49 additions and 74 deletions
+3 -2
View File
@@ -83,12 +83,12 @@ export default {
</van-checkbox-group>
```
### Checkbox API
| Attribute | Description | Type | Default | Accepted Values |
|-----------|-----------|-----------|-------------|-------------|
| name | Checkbox name | `Boolean` | `false` | - |
| v-model | Check status | `Boolean` | `false` | - |
| name | Checkbox name | `any` | - | - |
| disabled | Diable checkbox | `Boolean` | `false` | - |
| label-disabled | Whether to disable label click | `Boolean` | `false` | - |
| shape | Checkbox shape | `String` | `round` | `square` |
@@ -97,6 +97,7 @@ export default {
| Attribute | Description | Type | Default | Accepted Values |
|-----------|-----------|-----------|-------------|-------------|
| v-model | Names of all checked checkboxes | `Array` | - | - |
| disabled | Disable all checkboxes | `Boolean` | `false` | - |
| max | Maximum amount of checked options | `Number` | `0`(Unlimited) | - |
+9 -15
View File
@@ -10,11 +10,13 @@ Vue.use(Radio);
### Usage
#### Basic Usage
Use `v-model` to bind check status of radio. The value will be set to the name of radio when radio get checked.
Use `v-model` to bind the name of checked radio
```html
<van-radio name="1" v-model="radio">Radio 1</van-radio>
<van-radio name="2" v-model="radio">Radio 2</van-radio>
<van-radio-group v-model="radio">
<van-radio name="1">Radio 1</van-radio>
<van-radio name="2">Radio 2</van-radio>
</van-radio-group>
```
```javascript
@@ -30,16 +32,7 @@ export default {
#### Disabled
```html
<van-radio name="1" v-model="radio" disabled>Disabled</van-radio>
<van-radio name="2" v-model="radio" disabled>Disabled and checked</van-radio>
```
#### Radio Group
When Radios are inside a RadioGroup, the checked radio's name is bound with CheckboxGroup by `v-model`.
```html
<van-radio-group v-model="radio">
<van-radio-group v-model="radio" disabled>
<van-radio name="1">Radio 1</van-radio>
<van-radio name="2">Radio 2</van-radio>
</van-radio-group>
@@ -60,13 +53,14 @@ When Radios are inside a RadioGroup, the checked radio's name is bound with Chec
| Attribute | Description | Type | Default | Accepted Values |
|-----------|-----------|-----------|-------------|-------------|
| disabled | Diable radio | `Boolean` | `false` | - |
| name | Radio name | `Boolean` | `false` | - |
| name | Radio name | `any` | - | - |
| disabled | Whether to disable radio | `Boolean` | `false` | - |
### RadioGroup API
| Attribute | Description | Type | Default | Accepted Values |
|-----------|-----------|-----------|-------------|-------------|
| v-model | Name of checked radio | `any` | - | - |
| disabled | Diable all radios | `Boolean` | `false` | - |
### RadioGroup Event