feat: 调整首页组件目录结构
This commit is contained in:
54
pages/index/components/drawer/DrawerHome/index.vue
Normal file
54
pages/index/components/drawer/DrawerHome/index.vue
Normal file
@@ -0,0 +1,54 @@
|
||||
<template>
|
||||
<view class="drawer-home">
|
||||
<view class="drawer-home-nav">
|
||||
<uni-icons
|
||||
type="closeempty"
|
||||
size="22"
|
||||
color="#333333"
|
||||
class="close-icon"
|
||||
@click="closeDrawer"
|
||||
/>
|
||||
<text class="title">我的</text>
|
||||
</view>
|
||||
|
||||
<MineSetting v-if="isDrawerVisible" @closeDrawer="closeDrawer" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { defineEmits, ref, onMounted, onUnmounted } from "vue";
|
||||
import MineSetting from "../MineSetting/index.vue";
|
||||
|
||||
const emits = defineEmits(["closeDrawer"]);
|
||||
|
||||
const isDrawerVisible = ref(false);
|
||||
const closeDrawer = () => {
|
||||
console.log("关闭抽屉");
|
||||
isDrawerVisible.value = false;
|
||||
emits("closeDrawer");
|
||||
};
|
||||
|
||||
// 监听抽屉显示事件
|
||||
const handleDrawerShow = () => {
|
||||
isDrawerVisible.value = true;
|
||||
};
|
||||
|
||||
// 监听抽屉隐藏事件
|
||||
const handleDrawerHide = () => {
|
||||
isDrawerVisible.value = false;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
uni.$on("drawerShow", handleDrawerShow);
|
||||
uni.$on("drawerHide", handleDrawerHide);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
uni.$off("drawerShow", handleDrawerShow);
|
||||
uni.$off("drawerHide", handleDrawerHide);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import "./styles/index.scss";
|
||||
</style>
|
||||
25
pages/index/components/drawer/DrawerHome/styles/index.scss
Normal file
25
pages/index/components/drawer/DrawerHome/styles/index.scss
Normal file
@@ -0,0 +1,25 @@
|
||||
.drawer-home {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
background-color: #fff;
|
||||
padding-top: 44px;
|
||||
}
|
||||
|
||||
.drawer-home-nav {
|
||||
position: relative;
|
||||
padding: 12px;
|
||||
display: flex;
|
||||
justify-content: center; /* 文字水平居中 */
|
||||
align-items: center; /* 垂直居中 */
|
||||
|
||||
.title {
|
||||
font-size: 18px;
|
||||
text-align: center;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.close-icon {
|
||||
position: absolute;
|
||||
left: 12px; /* 距离左边12px */
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user