Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit04199a5

Browse files
authored
feat: importable $closeModal helper (#1088)
1 parent83a82cf commit04199a5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

‎src/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export { ELEMENT_REF, createNativeView } from './runtimeHelpers';
4040

4141
export*from'@vue/runtime-core';
4242
export{vShow}from'./directives/vShow';
43-
export{$showModal}from'./plugins/modals';
43+
export{$showModal,$closeModal}from'./plugins/modals';
4444
export{$navigateTo,$navigateBack}from'./plugins/navigation';
4545

4646
// creates a special root container that calls resetRoot whenever it's children change

‎src/plugins/modals.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ function resolveModalTarget(
6161
returnfalse;
6262
}
6363

64+
constmodalStack=[];
65+
6466
exportasyncfunction$showModal<T=any,P=any>(
6567
component:Component<P>,
6668
options:ShowModalOptions<P,T>={},
@@ -127,6 +129,9 @@ export async function $showModal<T = any, P = any>(
127129
});
128130
};
129131
constcloseModal=(...args:any[])=>{
132+
// remove view from modalStack
133+
modalStack.splice(modalStack.indexOf(view),1);
134+
130135
view.nativeView?.closeModal(...args);
131136
};
132137

@@ -144,5 +149,12 @@ export async function $showModal<T = any, P = any>(
144149

145150
view.mount(root);
146151
openModal();
152+
modalStack.push(view);
147153
});
148154
}
155+
156+
exportfunction$closeModal(...args){
157+
constview=modalStack.at(-1);
158+
159+
view?.context.config.globalProperties.$closeModal(...args);
160+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp