该组件提供了一种多端统一的 动作面板
样式与 IOS
对齐,在页面上的层级为 1010
在 Taro 文件中引入组件
import { AtActionSheet, AtActionSheetItem } from 'taro-ui-vue3'
组件依赖的样式文件(仅按需引用时需要)
@import "taro-ui-vue3/dist/style/components/action-sheet.scss";
<template>
<AtActionSheet
:isOpened="isOpened1"
@close="handleClose"
>
<AtActionSheetItem
@click="clickBtn1"
>
按钮一
</AtActionSheetItem>
<AtActionSheetItem
@click="clickBtn2"
>
按钮二
</AtActionSheetItem>
</AtActionSheet>
</template>
<script>
import Taro from '@tarojs/taro'
export default {
name: 'AtActionSheetDemo',
data() {
return {
isOpened1: true
}
},
methods: {
handleClose() {
this.isOpened1 = false
},
showToast (name) {
Taro.showToast({
icon: 'none',
title: name
})
},
clickBtn1() {
this.showToast('点击了按钮一')
},
clickBtn2() {
this.showToast('点击了按钮二')
},
}
}
</script>
<template>
<AtActionSheet
cancelText='取消'
:isOpened="isOpened2"
title='清除位置信息后, 别人将不能查看到你'
>
<AtActionSheetItem
@click="clickBtn1"
>
按钮一
</AtActionSheetItem>
<AtActionSheetItem
@click="clickBtn2"
>
按钮二
</AtActionSheetItem>
</AtActionSheet>
</template>
<template>
<AtActionSheet
cancelText='取消'
:isOpened="state.isOpened3"
@cancel="handleCancel"
@close="handleClose"
title='清除位置信息后, 别人将不能查看到你'
>
<AtActionSheetItem
@click="clickBtn1"
>
按钮一
</AtActionSheetItem>
<AtActionSheetItem
@click="clickBtn2"
>
按钮二
</AtActionSheetItem>
<AtActionSheetItem
@click="clickBtn3"
>
<text class='danger'>清除位置信息并退出</text>
</AtActionSheetItem>
</AtActionSheet>
</template>
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
title | 元素的标题 | String | - | - |
isOpened | 是否展示元素 | Boolean | - | false |
cancelText | 取消按钮的内容 | String | - | - |
事件名称 | 说明 | 返回参数 |
---|---|---|
onClose | 元素被关闭触发的事件 | - |
onCancel | 点击了底部取消按钮触发的事件 | - |
事件名称 | 说明 | 返回参数 |
---|---|---|
onClick | 点击 Item 触发的事件 | - |