[Doc] english document of all action components (#260)

* [bugfix] CouponList always show empty info

* [bugfix] add click feedback of buttons in components

* [Doc] add custom theme document

* [new feature] Notice bar support more props

* [bugfix] PullRefresh test cases

* [bugfix] unused NoticeBar style

* [bugfix] Swipe width calc error

* [Doc] english document of all action components
This commit is contained in:
neverland
2017-10-26 08:38:13 -05:00
committed by GitHub
parent 0cae221d5c
commit a7d8379514
10 changed files with 191 additions and 299 deletions
+38 -96
View File
@@ -1,33 +1,23 @@
<script>
import { Toast } from 'packages/index';
export default {
data() {
return {
show1: false,
show2: false,
show3: false,
actions1: [
{
name: '微信安全支付',
className: 'actionsheet-wx',
callback: this.handleActionClick
},
{
name: '支付宝支付',
loading: true
},
{
name: '信用卡支付'
},
{
name: '其他支付方式'
}
actions: [
{ name: 'Option1', callback: this.onClick },
{ name: 'Option2' },
{ name: 'Option3', loading: true }
]
};
},
methods: {
handleActionClick(item) {
console.log(item);
onClick(item) {
Toast(item.name);
}
}
}
@@ -45,14 +35,12 @@ Vue.component(Actionsheet.name, Actionsheet);
### Usage
#### Basic Usage
需要传入一个`actions`的属性,该属性为一个数组,数组的每一项是一个对象,可以根据下面的[action对象](#actions)设置你想要的信息。
Use `actions` prop to set options of actionsheet.
:::demo Basic Usage
```html
<van-button @click="show1 = true">弹出actionsheet</van-button>
<van-actionsheet v-model="show1" :actions="actions1">
</van-actionsheet>
<van-button @click="show1 = true">Show Actionsheet</van-button>
<van-actionsheet v-model="show1" :actions="actions" />
```
```javascript
@@ -60,83 +48,40 @@ export default {
data() {
return {
show1: false,
actions1: [
{
name: '微信安全支付',
className: 'actionsheet-wx',
callback: this.handleActionClick
},
{
name: '支付宝支付',
loading: true
},
{
name: '信用卡支付'
},
{
name: '其他支付方式'
}
actions: [
{ name: 'Option1', callback: this.onClick },
{ name: 'Option2' },
{ name: 'Option3', loading: true }
]
};
},
methods: {
handleActionClick(item) {
console.log(item);
onClick(item) {
Toast(item.name);
}
}
}
```
:::
#### 带取消按钮的 Actionsheet
#### Actionsheet with cancel button
如果传入了`cancelText`属性,且不为空,则会在下方显示一个取消按钮,点击会将当前`Actionsheet`关闭。
:::demo 带取消按钮的 Actionsheet
:::demo Actionsheet with cancel button
```html
<van-button @click="show2 = true">弹出带取消按钮的actionsheet</van-button>
<van-actionsheet v-model="show2" :actions="actions1" cancel-text="取消">
</van-actionsheet>
```
```javascript
export default {
data() {
return {
show2: false,
actions1: [
{
name: '微信安全支付',
className: 'actionsheet-wx',
callback: this.handleActionClick
},
{
name: '支付宝支付',
loading: true
},
{
name: '信用卡支付'
},
{
name: '其他支付方式'
}
]
};
}
}
<van-button @click="show2 = true">Show Actionsheet with cancel button</van-button>
<van-actionsheet v-model="show2" :actions="actions" cancel-text="Cancel" />
```
:::
#### 带标题的 Actionsheet
#### Actionsheet with title
Actionsheet will get another style if there is a `title` prop.
如果传入了`title`属性,且不为空,则另外一种样式的`Actionsheet`,里面内容需要自定义。
:::demo 带标题的 Actionsheet
:::demo Actionsheet with title
```html
<van-button @click="show3 = true">弹出带标题的actionsheet</van-button>
<van-actionsheet v-model="show3" title="支持以下配送方式" class="title-actionsheet">
<p>一些内容</p>
<van-button @click="show3 = true">Show Actionsheet with title</van-button>
<van-actionsheet v-model="show3" title="Title">
<p>Content</p>
</van-actionsheet>
```
:::
@@ -145,21 +90,18 @@ export default {
| Attribute | Description | Type | Default | Accepted Values |
|-----------|-----------|-----------|-------------|-------------|
| actions | 行动按钮数组 | `Array` | `[]` | - |
| title | 标题 | `String` | - | - |
| cancelText | 取消按钮文案 | `String` | - | - |
| overlay | 是否显示遮罩 | `Boolean` | - | - |
| closeOnClickOverlay | 点击遮罩是否关闭`Actionsheet` | `Boolean` | - | - |
| actions | Options | `Array` | `[]` | - |
| title | Title | `String` | - | - |
| cancelText | Text of cancel button | `String` | - | - |
| overlay | Whether to show overlay | `Boolean` | - | - |
| closeOnClickOverlay | Whether to close when click overlay | `Boolean` | - | - |
### actions
`API`中的`actions`为一个对象数组,数组中的每一个对象配置每一列,每一列有以下`key`
### Data struct of actions
| key | Description |
|-----------|-----------|
| name | 标题 |
| subname | 二级标题 |
| className | 为对应列添加特殊的`class` |
| loading | 是否是`loading`状态 |
| callback | 点击时的回调。该回调接受一个参数,参数为当前点击`action`的对象信息 |
| name | Title |
| subname | Subtitle |
| className | className for the option |
| loading | Whether to be loading status |
| callback | Triggered when click option |