[Doc] rename component README file (#3662)

This commit is contained in:
neverland
2019-06-27 14:22:40 +08:00
committed by GitHub
parent a56f96c246
commit ddb24e6762
119 changed files with 4 additions and 3 deletions
+99
View File
@@ -0,0 +1,99 @@
# Search
### Install
``` javascript
import { Search } from 'vant';
Vue.use(Search);
```
## Usage
### Basic Usage
```html
<van-search placeholder="Placeholder" v-model="value" />
```
```javascript
export default {
data() {
value: ''
}
}
```
### Listen to Events
`search` event will be triggered when click the search button on the keyboard.
`cancel` event will be triggered when click the cancel button.
Tips: There will be a search button on the keyboard when Search is inside a form in iOS.
```html
<form action="/">
<van-search
v-model="value"
placeholder="Placeholder"
show-action
@search="onSearch"
@cancel="onCancel"
/>
</form>
```
### Custom Button
Use `action` slot to custom right button, `cancel` event will no longer be triggered when use this slot
```html
<van-search
v-model="value"
show-action
shape="round"
@search="onSearch"
>
<div slot="action" @click="onSearch">Search</div>
</van-search>
```
## API
### Props
Search support all native properties of input tagsuch as `maxlength`、`placeholder`、`autofocus`
| Attribute | Description | Type | Default |
|------|------|------|------|
| label | Search label | `String` | - |
| shape | Can be set to `round` | `String` | `square` |
| background | Background color | `String` | `#f2f2f2` |
| clearable | Whether to be clearable | `Boolean` | `true` |
| show-action | Whether to show right button | `Boolean` | `false` |
| disabled | Whether to disable field | `Boolean` | `false` |
| readonly | Whether to be readonly | `Boolean` | `false` |
| error | Whether to show error info | `Boolean` | `false` |
| input-align | Input text align, can be set to `center` `right` | `String` | `left` |
| left-icon | Left icon name | `String` | `search` |
| right-icon | Right icon name | `String` | - |
### Events
Search support all native events of input tagsuch as `focus`、`blur`、`keypress`
| Event | Description | Arguments |
|------|------|------|
| cancel | Triggered when click cancel button | - |
| search | Triggered when confirm search | - |
| clear | Triggered when click clear icon | - |
### Slots
| Name | Description |
|------|------|
| label | Custom Search label |
| action | Custom right button, displayed when `showAction` is true |
| left-icon | Custom left icon |
| right-icon | Custom right icon |