138 lines
3.0 KiB
Vue
138 lines
3.0 KiB
Vue
|
<template>
|
|||
|
<div class="categories">
|
|||
|
<div class="content-wrap">
|
|||
|
<el-menu
|
|||
|
:popper-offset="0"
|
|||
|
popper-class="categories-popper"
|
|||
|
mode="horizontal"
|
|||
|
:show-timeout="0"
|
|||
|
:hide-timeout="0"
|
|||
|
>
|
|||
|
<CategoryChildren
|
|||
|
v-for="category in categories"
|
|||
|
:key="category.uid"
|
|||
|
:index="category.uid"
|
|||
|
:category="category"
|
|||
|
/>
|
|||
|
</el-menu>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</template>
|
|||
|
|
|||
|
<script>
|
|||
|
import CategoryChildren from '@/components/layout/CategoryChildren'
|
|||
|
|
|||
|
export default {
|
|||
|
name: 'Categories',
|
|||
|
components: { CategoryChildren },
|
|||
|
props: {
|
|||
|
// 栏目树
|
|||
|
categories: {
|
|||
|
required: true
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
</script>
|
|||
|
|
|||
|
<style scoped lang="scss">
|
|||
|
.categories {
|
|||
|
background-color: var(--primary-color-dark);
|
|||
|
:deep(.el-menu) {
|
|||
|
// 选中的栏目,Nuxt会自动选中并增加该class
|
|||
|
.router-link-active {
|
|||
|
background-color: var(--color-white);
|
|||
|
color: var(--primary-color-dark) !important;
|
|||
|
border-radius: 8px;
|
|||
|
line-height: 38px;
|
|||
|
font-weight: bold;
|
|||
|
transition: all .3s;
|
|||
|
&:hover {
|
|||
|
border-radius: 0;
|
|||
|
}
|
|||
|
}
|
|||
|
// 栏目标题
|
|||
|
a,label {
|
|||
|
display: flex;
|
|||
|
align-items: center;
|
|||
|
width: 100%;
|
|||
|
color: var(--color-white);
|
|||
|
cursor: pointer;
|
|||
|
padding: 0 35px;
|
|||
|
.category-icon {
|
|||
|
margin-right: 5px;
|
|||
|
}
|
|||
|
.image-icon {
|
|||
|
width: 20px !important;
|
|||
|
}
|
|||
|
}
|
|||
|
// 隐藏下拉箭头
|
|||
|
.el-sub-menu__icon-arrow {
|
|||
|
display: none;
|
|||
|
}
|
|||
|
// 根栏目
|
|||
|
.el-menu-item,.el-sub-menu {
|
|||
|
padding: 10px 0;
|
|||
|
box-sizing: border-box;
|
|||
|
text-align: center;
|
|||
|
border-bottom: 0 !important;
|
|||
|
&.is-active {
|
|||
|
color: var(--primary-color-dark) !important;
|
|||
|
}
|
|||
|
}
|
|||
|
// 存在子栏目的栏目标题
|
|||
|
.el-sub-menu__title {
|
|||
|
padding: 0;
|
|||
|
border-bottom: 0;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
</style>
|
|||
|
<style lang="scss">
|
|||
|
.categories-popper {
|
|||
|
border: 0 !important;
|
|||
|
.el-menu {
|
|||
|
background-color: #fff !important;
|
|||
|
// 子栏目标题
|
|||
|
a,label {
|
|||
|
display: block;
|
|||
|
width: 100%;
|
|||
|
height: 100%;
|
|||
|
text-align: left;
|
|||
|
color: var(--font-color);
|
|||
|
&:hover {
|
|||
|
color: var(--color-white);
|
|||
|
}
|
|||
|
}
|
|||
|
.el-menu-item {
|
|||
|
min-width: 200px;
|
|||
|
background-color: #fff;
|
|||
|
font-size: var(--font-size-middle);
|
|||
|
text-align: center;
|
|||
|
transition: none;
|
|||
|
&:hover {
|
|||
|
background-color: var(--primary-color-light);
|
|||
|
color: var(--color-white);
|
|||
|
}
|
|||
|
}
|
|||
|
// 带子栏目的标题
|
|||
|
.el-sub-menu__title {
|
|||
|
background-color: var(--color-white);
|
|||
|
font-size: var(--font-size-middle);
|
|||
|
// 箭头
|
|||
|
.el-sub-menu__icon-arrow {
|
|||
|
color: var(--font-color);
|
|||
|
}
|
|||
|
&:hover {
|
|||
|
background-color: var(--primary-color-light);
|
|||
|
a {
|
|||
|
color: var(--color-white) !important;
|
|||
|
}
|
|||
|
.el-sub-menu__icon-arrow {
|
|||
|
color: var(--color-white) !important;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
</style>
|