Skip to content

Commit b55d13f

Browse files
committed
修正sidebar顯示
1 parent de75e45 commit b55d13f

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/components/Sidebar.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<el-aside class="md:flex bg-gray-800 text-white w-40 flex flex-col" :class="{ 'hidden': sidebarOpen}">
2+
<el-aside class="md:flex bg-gray-800 text-white w-40 flex flex-col">
33
<div class="p-4 text-xl font-bold">使用者</div>
44
<el-menu
55
default-active="1"
@@ -19,10 +19,6 @@
1919

2020
<script setup>
2121
defineProps({
22-
sidebarOpen: {
23-
type: Boolean,
24-
default: true
25-
},
2622
sidebarList: {
2723
type: Array,
2824
default: () => []

src/views/HomeView.vue

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
22
<main>
3-
<el-container class="h-screen">
4-
<Sidebar :sidebarOpen="sidebarOpen" @singOut="singOut" :sidebarList="sidebarList" @getTableData="getTableData"/>
3+
<el-container class="h-screen relative">
4+
<Sidebar :class="{ 'hidden': sidebarOpen, 'z-50 fixed inset-y-0 left-0': !sidebarOpen}" @singOut="singOut" :sidebarList="sidebarList" @getTableData="getTableData"/>
55
<el-container>
6-
<el-header class="bg-white border-b flex items-center justify-between md:justify-end">
7-
<el-icon @click="toggleSidebar" class="text-black block md:hidden cursor-pointer"><Menu /></el-icon>
8-
<el-button type="primary" class="bg-gray-500 hover:bg-gray-600 border-gray-500 hover:border-gray-600">新增</el-button>
6+
<el-header class="bg-white border-b flex items-center justify-between md:justify-end" >
7+
<el-icon @click="toggleSidebar" class="text-black block md:hidden cursor-pointer" :class="{'fixed left-32 z-50 text-white': !sidebarOpen}"><Menu /></el-icon>
8+
<el-button type="primary" :class="{'fixed right-5' : !sidebarOpen}" class="bg-gray-500 hover:bg-gray-600 border-gray-500 hover:border-gray-600">新增</el-button>
99
</el-header>
1010

1111
<Table :tableData="tableData" :tableHeader="tableHeader" @openModal="openModal" :tableTitle="tableTitle"/>
@@ -17,7 +17,7 @@
1717
</template>
1818

1919
<script setup>
20-
import { ref, nextTick, onBeforeMount } from 'vue'
20+
import { ref, onBeforeMount } from 'vue'
2121
import { useRouter } from 'vue-router'
2222
import { Menu } from '@element-plus/icons-vue'
2323
import { ElMessage } from 'element-plus'
@@ -32,7 +32,6 @@
3232
const sidebarOpen = ref(true)
3333
const toggleSidebar = async () => {
3434
sidebarOpen.value = !sidebarOpen.value
35-
// await nextTick()
3635
}
3736
3837
const sidebarList = ref([])

0 commit comments

Comments
 (0)