1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
| <template>
<div class="aside-container">
<ul class="user-select-none menu">
<li v-for="item in menuList" :key="item.id" class="menu-item">
<router-link :to="item.pah">{{ item.name }}</router-link>
</li>
</ul>
</div>
</template>
<script>
export default {
name: "Aside",
data() {
return {
menuList: [
{ id: 1, name: '用户管理', path: '/home/users'},
{ id: 1, name: '权限管理', path: '/home/rights'},
{ id: 1, name: '商品管理', path: '/home/goods'},
{ id: 1, name: '订单管理', path: '/home/orders'},
{ id: 1, name: '系统设置', path: '/home/settings'}
]
}
}
}
</script>
<style>
.aside-container {
height: 100%;
width: 250px;
border-right: 1px solid #eaeaea;
.menu {
list-style-type: none;
padding: 0;
.menu-item {
line-height: 50px;
font-weight: bold;
font-size: 14px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
&:hover {
background-color: #efefef;
cursor: pointer;
}
a {
color: black;
display: block;
padding-left: 30px;
&:hover {
text-decoration: none;
}
}
}
}
}
// router-link-active是router-link元素特有的选中状态class,可以用来实现选中后的效果。
.router-link-active {
background-color: #efefef;
box-sizing: border-box;
position: relative;
&::before {
content: ''; // 如果没有content,绿色小长条会显示不出来。
display: block;
position: absolute; //绝对定位让绿色小长条能够盖在背景上面
left: 0;
top: 0;
width: 4px;
height: 100%;
background-color: #42b983;
}
}
</style>
|