关闭所有弹窗
说明:
- 调用
$tinylayer.closeAll()可关闭所有弹窗; - 可传入一个
false参数,即:$tinylayer.closeAll( false ),此时关闭弹窗将不会有淡出效果; - 此方法适用于所有模式的弹窗,一般用于在页面进行切换时,关闭存在的所有弹窗。
vue
<template>
<button @click="openA">打开弹窗 A</button>
<TinyLayer v-model="visibleA" title="弹窗 A">
<button @click="openB">打开弹窗 B</button>
</TinyLayer>
<TinyLayer v-model="visibleB" title="弹窗 B" :mask-visible="false">
<button @click="openC">打开弹窗 C</button>
</TinyLayer>
<TinyLayer v-model="visibleC" title="弹窗 C" :mask-visible="false">
<button @click="openD">打开弹窗 D</button>
</TinyLayer>
<TinyLayer v-model="visibleD" title="弹窗 D" :mask-visible="false">
<button @click="closeAll">关闭所有弹窗(有淡出动画)</button>
<br><br>
<button @click="closeAllFalse">关闭所有弹窗(没有淡出动画)</button>
</TinyLayer>
</template>
<script setup>
import { ref } from "vue";
const visibleA = ref( false );
const visibleB = ref( false );
const visibleC = ref( false );
const visibleD = ref( false );
const openA = () => {
visibleA.value = true;
}
const openB = () => {
visibleB.value = true;
}
const openC = () => {
visibleC.value = true;
}
const openD = () => {
visibleD.value = true;
}
const closeAll = () => {
$tinylayer.closeAll();
}
const closeAllFalse = () => {
$tinylayer.closeAll( false );
}
</script>