feat: 点击空白处关闭弹窗或者下拉菜单
parent
ad832ad408
commit
c1f5f681ae
@ -1,6 +1,8 @@
|
||||
export * from "./auth";
|
||||
export * from "./copy";
|
||||
export * from "./longpress";
|
||||
export * from "./optimize";
|
||||
export * from "./perms";
|
||||
export * from "./ripple";
|
||||
export * from './auth';
|
||||
export * from './copy';
|
||||
export * from './longpress';
|
||||
export * from './optimize';
|
||||
export * from './perms';
|
||||
export * from './ripple';
|
||||
|
||||
export * from './clickOutSide';
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-card title="点击空白区域隐藏节点">
|
||||
<button
|
||||
ref="btnRef"
|
||||
@click="toggleDropdown"
|
||||
>
|
||||
点击显示下拉菜单
|
||||
</button>
|
||||
</el-card>
|
||||
<div
|
||||
v-if="isDropdownVisible"
|
||||
v-clickOutSide="{
|
||||
handler: hideDropdown,
|
||||
exclude: btnRef,
|
||||
}"
|
||||
class="dropdown"
|
||||
>
|
||||
<!-- 菜单内容 -->
|
||||
<p>这是一个下拉菜单</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="jsx">
|
||||
import { ref } from 'vue';
|
||||
|
||||
const btnRef = ref(null);
|
||||
const isDropdownVisible = ref(false);
|
||||
|
||||
const toggleDropdown = () => {
|
||||
isDropdownVisible.value = !isDropdownVisible.value;
|
||||
};
|
||||
|
||||
const hideDropdown = () => {
|
||||
isDropdownVisible.value = false;
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.dropdown {
|
||||
border: 1px solid #ccc;
|
||||
padding: 10px;
|
||||
position: absolute;
|
||||
background: white;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
</style>
|
||||
@ -1,15 +1,9 @@
|
||||
<template>
|
||||
<el-card> 基础模版 </el-card>
|
||||
<el-card> 测试路由生成是否包含components </el-card>
|
||||
</template>
|
||||
|
||||
<script setup lang="jsx">
|
||||
import { ref } from 'vue';
|
||||
|
||||
defineOptions({
|
||||
name: 'DemoTools',
|
||||
});
|
||||
|
||||
const page = ref({});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
||||
Loading…
Reference in New Issue