mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-11-13 00:12:09 +08:00
* fix: Tabbar icon line-height * [new feature] progress add showPivot prop * [new feature] TabItem support vue-router * [new feature] update document header style * [Doc] add toast english ducoment * [new feature] add i18n support * feat: Extract demos from markdown * feat: Base components demos * [new feature] complete demo extract & translate * [fix] text cases * fix: add deepAssign test cases * fix: changelog detail * [new feature] AddressEdit support i18n
2.1 KiB
2.1 KiB
Actionsheet 行动按钮
使用指南
import { Actionsheet } from 'vant';
Vue.component(Actionsheet.name, Actionsheet);
代码演示
基础用法
需要传入一个actions的数组,数组的每一项是一个对象,对象属性见文档下方表格。
<van-actionsheet v-model="show" :actions="actions" />
export default {
data() {
return {
show: false,
actions: [
{
name: '选项',
callback: this.onClick
},
{
name: '信用卡支付'
},
{
name: '选项',
loading: true
}
]
};
},
methods: {
onClick(item) {
Toast(item.name);
}
}
}
带取消按钮的 Actionsheet
如果传入了cancelText属性,且不为空,则会在下方显示一个取消按钮,点击会将当前Actionsheet关闭。
<van-actionsheet v-model="show" :actions="actions" cancelText="取消" />
带标题的 Actionsheet
如果传入了title属性,且不为空,则另外一种样式的Actionsheet,里面内容需要自定义。
<van-actionsheet v-model="show" title="支持以下配送方式">
<p>一些内容</p>
</van-actionsheet>
API
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|---|---|---|---|---|
| actions | 行动按钮数组 | Array |
[] |
- |
| title | 标题 | String |
- | - |
| cancelText | 取消按钮文案 | String |
- | - |
| overlay | 是否显示遮罩 | Boolean |
- | - |
| closeOnClickOverlay | 点击遮罩是否关闭Actionsheet |
Boolean |
- | - |
actions
API中的actions为一个对象数组,数组中的每一个对象配置每一列,每一列有以下key:
| key | 说明 |
|---|---|
| name | 标题 |
| subname | 二级标题 |
| className | 为对应列添加特殊的class |
| loading | 是否是loading状态 |
| callback | 点击时的回调。该回调接受一个参数,参数为当前点击action的对象信息 |