Skip to content

ActionSheet 动作面板

介绍

从底部弹出的动作菜单面板。

基础用法

html
<template>
  <nut-action-sheet
    v-model:visible="visible"
    :menu-items="items"
    @choose="onChoose"
  ></nut-action-sheet>
</template>
ts
import type { ActionSheetOption } from "nutui-uniapp";

const visible = ref(false);

const items = ref([
  { name: "选项一" },
  { name: "选项二" },
  { name: "选项三" }
]);

function onChoose(item: ActionSheetOption, index: number) {
  console.log("choose", item, index);
}

展示取消按钮

html
<template>
  <nut-action-sheet
    v-model:visible="visible"
    :menu-items="items"
    cancel-txt="取消"
    @choose="onChoose"
  ></nut-action-sheet>
</template>

展示描述信息

html
<template>
  <nut-action-sheet
    v-model:visible="visible"
    :menu-items="items"
    description="这是一段展示信息"
    @choose="onChoose"
  ></nut-action-sheet>
</template>

选项状态

html
<template>
  <nut-action-sheet
    v-model:visible="visible"
    :menu-items="items"
    choose-tag-value="着色选项"
    @choose="onChoose"
  ></nut-action-sheet>
</template>
ts
const items = ref([
  { name: "着色选项" },
  { name: "禁用选项", disable: true }
]);

自定义内容

html
<template>
  <nut-action-sheet v-model:visible="visible" title="标题">
    <text>自定义内容</text>
  </nut-action-sheet>
</template>

API

Props

参数说明类型可选值默认值
v-model:visible是否展示动作面板boolean-false
menu-items列表项Array-[]
option-tag设置列表项标题展示使用参数string-name
option-sub-tag设置列表项二级标题展示使用参数string-subname
choose-tag-value设置选中项的值,和 option-tag 的值对应string--
custom-color选中项颜色,当 choose-tag-value === option-tag 时生效string-#ee0a24
title设置列表项标题string--
description设置列表项副标题 / 描述string--
cancel-txt取消文案string-取消
close-abled遮罩层是否可关闭boolean-true
round 1.7.11是否显示圆角boolean-true
overlay 1.7.11是否显示遮罩boolean-true
pop-class自定义弹框类名string--
pop-style 1.7.11自定义弹框样式CSSProperties--
overlay-class自定义遮罩层类名string--
overlay-style自定义遮罩层样式string--
lock-scroll H5 1.7.11遮罩显示时的背景是否锁定boolean-true
safe-area-inset-bottom 1.7.11是否开启 iphone 系列全面屏底部安全区适配boolean-true
参数说明类型
name标题string
subname二级标题string
color选项字体颜色(选中项颜色层级 > 选项字体颜色)string
loading是否为 loading 状态boolean
disable是否为禁用状态boolean

Events

事件名说明类型
choose选择之后触发(item: ActionSheetOption, index: number) => void
cancel点击取消文案时触发() => void
close点击遮罩层时触发() => void

主题定制

样式变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 组件

名称默认值
--nut-actionsheet-light-color#f6f6f6
--nut-actionsheet-item-border-bottomnone
--nut-actionsheet-item-font-sizevar(--nut-font-size-2)
--nut-actionsheet-item-subdesc-font-sizevar(--nut-font-size-1)
--nut-actionsheet-item-cancel-border-top1px solid var(--nut-actionsheet-light-color)
--nut-actionsheet-item-line-height24px
--nut-actionsheet-item-font-colorvar(--nut-title-color)

MIT Licensed