component-右侧抽屉组件

1.右侧抽屉组件

点击筛选,右侧抽屉滑出,点击取消或者点击空白处抽屉收起。

2.代码

javascript 复制代码
<template>
	<div class="all" @click="hidden()">
        <!-- 抽屉 -->
		<div class="drawer">
			<div class="drawerBox" id="drawerBox" :class="{ show: isShow }">
                <!-- 头部 -->
				<div class="BoxHeader">
					<span class="boxFilterTitle">xxxx</span>
					<span class="off" @click="closeS">
						<svg t="1686011566423" class="icon" viewBox="0 0 1024 1024" p-id="4236" width="16" height="16">
							<path d="M801.856 734.016 579.904 512l222.016-222.016c18.816-18.816 18.88-49.152 0.064-67.968-18.752-18.752-49.216-18.752-67.904 0L512 444.032 289.92 222.016c-18.688-18.752-49.088-18.752-67.904 0C203.328 240.768 203.328 271.232 222.144 290.048L444.096 512l-222.016 221.952c-18.816 18.752-18.816 49.152-0.064 67.968C231.424 811.392 243.84 816 256 816s24.576-4.608 33.92-14.016L512 579.968l222.08 222.016c9.408 9.344 21.696 14.016 33.92 14.016 12.288 0 24.576-4.608 33.92-14.016C820.672 783.104 820.736 752.768 801.856 734.016z" p-id="4237" fill="#8a8a8a"></path>
						</svg>
					</span>
				</div>
				<!-- 内容 -->
				<div class="BoxContent" style="backgroundColor:green">
				</div>
                <!-- 底部 -->
				<div class="BoxBottom" style="display:flex;align-items:center;justify-content:center">
                    <a-button class="button" type="primary">筛选</a-button>
                    <a-button class="button" type="sync" style="margin-left:5%">取消</a-button>
				</div>
			</div>
            <!-- 筛选 -->
			<div @click="open()" id="search" style="width:60px;cursor: pointer;top:2%;right:100px;z-index:999; position: absolute;">
				<svg t="1686017135854" class="icon icons" viewBox="0 0 1024 1024" p-id="5444" width="20" height="20">
					<path d="M544.064 472a32 32 0 0 1 8.096-21.248L696.8 288H327.36l144.64 162.752a32 32 0 0 1 8.096 21.248V704l64-48v-184z m64 200a32 32 0 0 1-12.8 25.6l-128 96a32 32 0 0 1-51.2-25.6v-283.84L232.16 277.248C213.76 256.64 228.448 224 256.064 224h512c27.616 0 42.24 32.64 23.904 53.248l-183.904 206.912V672z" fill="#515151" p-id="5445"></path>
				</svg>
				<span class="filter">筛选</span>
			</div>
		</div>
	</div>
</template>
<script>
export default {
	name: "drawerBox",
	data(){
	return{
		    isShow: false,
        }
	},
	methods: {
		hidden() {
			var drawerBox = document.getElementById("drawerBox");
			var search = document.getElementById("search");
			if (drawerBox && search) {
				if (!drawerBox.contains(event.target) && !search.contains(event.target)) {
				this.isShow = false;
				}
			}
		},
		// 点击显示与否
		closeS() {
			this.isShow = false;
		},
		open() {
			this.isShow = true;
		},
	}
}
</script>
<style lang="less" scoped>
.all {
    width: 100%;
    height: 100%;
    background-color: rgb(255, 255, 255);
}
.drawer {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
/* 搜索 */
.boxFilterTitle {
    display: block;
    width: 12%;
    height: 50%;
    float: left;
    margin-top: 2.7%;
    color: #46494d;
    font-size: 14px;
    padding-left: 3%;
}
.boxFilterTitle:hover {
    color: #1890ff;
    path {
        fill: #1890ff;
    }
}

/* 关闭 */
.off {
    margin-left: 77%;
    cursor: pointer;
    display: block;
    margin-top: 2.7%;
    float: left;
    width: 10%;
    height: 50%;
}
.off:hover{
    color: black;
    path:hover{
        fill: red;
}
}
/* 抽屉盒子 */
.drawerBox {
    position: fixed;
    z-index: 1000;
    top: 17%;
    width: 390px;
    height: 81%;
    border-left: 1px solid #cfd8dc !important;
    box-shadow: 0px 3px 12px rgb(168, 162, 162);
    transition: all 0.6s ease;
    right: -400px;
    padding: 0px 10px 0px 0px;
    border-top-left-radius: 1%;
    border-bottom-left-radius: 1%;
    background-color: rgb(255, 255, 255);
}
  
.show {
    right: 0;
}
  
/* 过滤图标 */
.icons {
    float: left;
}
  
.filter {
    display: block;
    width: 50%;
    height: 100%;
    float: left;
    align-items: center;
    padding-left: 2%;
    font-size: 14px;
}
  
/* 主体内容 */
.BoxHeader,
.BoxContent,
.BoxBottom {
    margin-right: 15%;
}
  
.BoxHeader {
    margin-top: 1%;
    height: 6%;
    width: 100%;
    border: 1px solid #ddd;
    border-top: none;
    border-top-left-radius: 1%;
}

.BoxContent {
    height: 80%;
    width: 100%;
    border-right: 1px solid #ddd;
}

.BoxBottom {
    height: 10%;
    border: 1px solid #ddd;
    border-bottom: none;
    width: 100%;
    border-left: none;
    border-top-left-radius: 1%;
    border-bottom-left-radius: 1%;
}  
</style>
相关推荐
李李李勃谦8 分钟前
鸿蒙PC配色方案工具:取色、配色生成与 CSS 导出
前端·css·华为·harmonyos
threelab14 分钟前
Three.js 咖啡杯烟雾效果 | 三维可视化 / AI 提示词
开发语言·javascript·人工智能
Jul1en_33 分钟前
Claude 迁移 Codex 工作流迁移与更新
java·服务器·前端·后端·ai编程
Heo35 分钟前
14_React 中的更新队列 updateQueue
前端·javascript·面试
前端 贾公子42 分钟前
解决浏览器端 globalThis is not defined 报错
前端·javascript·vue.js
宁雨桥44 分钟前
前端与AI结合实战分享
前端·人工智能
码农小河661 小时前
AI 一键生成 HTML/CSS/JS 静态网站【压缩包返回可直接提交】
css·人工智能·html
之歆1 小时前
DAY12_CSS3选择器全攻略 + 盒子新特性完全指南(下)
前端·javascript·css3
kyriewen111 小时前
代码写成一锅粥?3个设计模式让你的项目“起死回生”
开发语言·前端·javascript·设计模式·ecmascript
用户2367829801681 小时前
CSS 阴影生成器:从单层到多层叠加的艺术
css