diff --git a/packages/action-sheet/index.tsx b/packages/action-sheet/index.tsx
index 03daf8144..7504da7f5 100644
--- a/packages/action-sheet/index.tsx
+++ b/packages/action-sheet/index.tsx
@@ -2,8 +2,8 @@ import { use } from '../utils';
import { emit, inherit } from '../utils/functional';
import { PopupMixin } from '../mixins/popup';
import Icon from '../icon';
-import Loading from '../loading';
import Popup from '../popup';
+import Loading from '../loading';
// Types
import { CreateElement, RenderContext } from 'vue/types';
@@ -37,6 +37,10 @@ function ActionSheet(
) {
const { title, cancelText } = props;
+ function onInput(value: boolean) {
+ emit(ctx, 'input', value);
+ }
+
function onCancel() {
emit(ctx, 'input', false);
emit(ctx, 'cancel');
@@ -53,8 +57,16 @@ function ActionSheet(
}
}
- function onClickOption(item: ActionSheetItem, index: number) {
- return function (event: Event) {
+ function Content() {
+ if (slots.default) {
+ return
{slots.default()}
;
+ }
+ }
+
+ function Option(item: ActionSheetItem, index: number) {
+ const disabled = item.disabled || item.loading;
+
+ function onClickOption(event: MouseEvent) {
event.stopPropagation();
if (item.disabled || item.loading) {
@@ -70,51 +82,55 @@ function ActionSheet(
if (props.closeOnClickAction) {
emit(ctx, 'input', false);
}
- };
+ }
+
+ function OptionContent() {
+ if (item.loading) {
+ return ;
+ }
+
+ return [
+ {item.name},
+ item.subname && {item.subname}
+ ];
+ }
+
+ return (
+
+ {OptionContent()}
+
+ );
}
- const Option = (item: ActionSheetItem, index: number) => (
-
- {item.loading ? (
-
- ) : (
- [
- {item.name},
- item.subname && {item.subname}
- ]
- )}
-
- );
+ function CancelText() {
+ if (cancelText) {
+ return (
+
+ {cancelText}
+
+ );
+ }
+ }
return (
{
- emit(ctx, 'input', value);
- }}
+ onInput={onInput}
{...inherit(ctx)}
>
{Header()}
{props.actions.map(Option)}
- {slots.default && {slots.default()}
}
- {cancelText && (
-
- {cancelText}
-
- )}
+ {Content()}
+ {CancelText()}
);
}