add max height and disabled button

This commit is contained in:
Timi
2026-10-30 10:46:30 +08:00
parent dc61f29323
commit 817994953f
2 changed files with 13 additions and 3 deletions
+4
View File
@@ -28,10 +28,14 @@ demo-preview=../demos/bottom-popup/basic.vue
按钮文案传空字符串即可隐藏对应按钮;也可以分别用 `leftButton` / `rightButton` 插槽完全接管,插槽会收到 `onClick`。
通过 `left-button-disabled` 和 `right-button-disabled` 分别绑定默认按钮的禁用状态,默认均为 `false`。自定义插槽按钮的禁用状态由插槽自行控制。
## 高度
`height` 默认 `"auto"`,按内容撑开;传具体值(如 `"60vh"`)时内容区滚动、标题栏吸顶。
使用 `max-height` 限制弹层最大高度,例如 `max-height="80vh"`;内容超过最大高度时,内容区滚动。数字值以 `px` 为单位。未设置时不限制最大高度。
## API
<api-table name="BottomPopup" />
+9 -3
View File
@@ -1,10 +1,10 @@
<template>
<t-popup v-model="visible" placement="bottom" :z-index="props.zIndex" :overlay-props="props.overlayProps">
<div class="bottom-popup" :style="{ height: props.height }">
<div class="bottom-popup" :style="{ height: props.height, maxHeight: props.maxHeight }">
<div v-if="hasHeader" class="header">
<div class="button left">
<slot name="leftButton" :on-click="emitLeftButtonClick">
<t-button v-if="leftButtonText" variant="text" size="small" @click="emitLeftButtonClick">
<t-button v-if="leftButtonText" variant="text" size="small" :disabled="props.leftButtonDisabled" @click="emitLeftButtonClick">
<span v-text="leftButtonText" />
</t-button>
</slot>
@@ -16,7 +16,7 @@
</div>
<div class="button right">
<slot name="rightButton" :on-click="emitRightButtonClick">
<t-button v-if="rightButtonText" theme="primary" variant="text" size="small" @click="emitRightButtonClick">
<t-button v-if="rightButtonText" theme="primary" variant="text" size="small" :disabled="props.rightButtonDisabled" @click="emitRightButtonClick">
<span v-text="rightButtonText" />
</t-button>
</slot>
@@ -38,7 +38,13 @@ export interface BottomPopupProps {
modelValue?: boolean;
leftButtonText?: string;
rightButtonText?: string;
/** 禁用左侧默认按钮。 */
leftButtonDisabled?: boolean;
/** 禁用右侧默认按钮。 */
rightButtonDisabled?: boolean;
height?: string | number;
/** 弹层最大高度,数字以 px 为单位。 */
maxHeight?: string | number;
title?: string;
zIndex?: number;
overlayProps?: Record<string, unknown>;