Blogger Information
Blog 47
fans 0
comment 0
visits 21048
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Element和后台搭建
P粉036614676
Original
425 people have browsed it

1、element 安装

1.npm 安装

npm i element-ui -S

2. CDN

<!-- 引入样式 -->

<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!-- 引入组件库 -->

<script src="https://unpkg.com/element-ui/lib/index.js"></script>

2、后台管理系统首页搭建

  1. <!-- 1、新建 /src/views/Index/Index.vue 文件 -->
  2. <template>
  3. <el-container class="layout" style="height: 100%">
  4. <aside style="height: 100%">
  5. <el-menu default-active="-1" class="el-menu-vertical-demo" :collapse="isCollapse" active-text-color="#ffd04b" background-color="#545c64" text-color="#fff">
  6. <div class="logo">
  7. <router-link to="/" class="router">
  8. <img src="" alt="logo" />
  9. <h1>phpAdmin</h1>
  10. </router-link>
  11. </div>
  12. <router-link to="/">
  13. <el-menu-item index="-1">
  14. <template #title>首页</template>
  15. </el-menu-item>
  16. </router-link>
  17. <el-sub-menu index="3">
  18. <template #title>
  19. <span>后台管理系统</span>
  20. </template>
  21. <router-link to="/admin/user">
  22. <el-menu-item index="3-1">
  23. <span>管理员管理</span>
  24. </el-menu-item>
  25. </router-link>
  26. <router-link to="/admin/">
  27. <el-menu-item index="3-2">
  28. <span>系统管理</span>
  29. </el-menu-item>
  30. </router-link>
  31. </el-sub-menu>
  32. <el-sub-menu index="2">
  33. <template #title>
  34. <span>课袋鼠项目</span>
  35. </template>
  36. <router-link to="/ad">
  37. <el-menu-item index="2-1">
  38. <span>广告管理</span>
  39. </el-menu-item>
  40. </router-link>
  41. <router-link to="/course">
  42. <el-menu-item index="2-2">
  43. <span>课程管理</span>
  44. </el-menu-item>
  45. </router-link>
  46. <el-menu-item index="2-3">
  47. <span>用户管理</span>
  48. </el-menu-item>
  49. <el-menu-item index="2-4">
  50. <span>订单管理</span>
  51. </el-menu-item>
  52. <el-menu-item index="2-5">
  53. <span>优惠券管理</span>
  54. </el-menu-item>
  55. </el-sub-menu>
  56. </el-menu>
  57. <div class="flexible" @click="isCollapse = !isCollapse">
  58. <el-icon v-if="isCollapse" color="white" :size="40"><ArrowRight /></el-icon>
  59. <el-icon v-else color="white" :size="40"><ArrowLeft /></el-icon>
  60. </div>
  61. </aside>
  62. <el-container>
  63. <el-header style="text-align: right; font-size: 20px">
  64. <div class="toolbar">
  65. <el-dropdown size="large" type="primary">
  66. <span>{{name}}<el-icon style="margin-left: 8px; margin-top: 1px"><ArrowDown /></el-icon></span>
  67. <template #dropdown>
  68. <el-dropdown-menu>
  69. <el-dropdown-item>个人中心</el-dropdown-item>
  70. <el-dropdown-item>退出</el-dropdown-item>
  71. </el-dropdown-menu>
  72. </template>
  73. </el-dropdown>
  74. </div>
  75. </el-header>
  76. <el-main>
  77. <router-view></router-view>
  78. </el-main>
  79. </el-container>
  80. </el-container>
  81. </template>
  82. <script>
  83. import { reactive, toRefs } from "vue"
  84. export default {
  85. name: "App",
  86. setup() {
  87. // 获取左侧菜单和用户信息
  88. const state = reactive({
  89. isCollapse: false,
  90. name : "欧阳克"
  91. });
  92. return {
  93. ...toRefs(state),
  94. };
  95. }
  96. };
  97. </script>
  98. <style>
  99. a {
  100. text-decoration: none;
  101. }
  102. .layout {
  103. background-color: #f0f2f5;
  104. }
  105. .layout .el-header {
  106. position: relative;
  107. background-color: white;
  108. color: var(--el-text-color-primary);
  109. }
  110. .layout aside {
  111. color: var(--el-text-color-primary);
  112. background: #001529;
  113. }
  114. .layout .el-menu {
  115. border-right: none;
  116. }
  117. .layout .el-main {
  118. margin: 30px 10px;
  119. background-color: white;
  120. }
  121. .layout .toolbar {
  122. display: inline-flex;
  123. align-items: center;
  124. justify-content: center;
  125. height: 100%;
  126. right: 20px;
  127. }
  128. aside {
  129. position: relative;
  130. }
  131. .flexible {
  132. background-color: #002140;
  133. text-align: center;
  134. position: absolute;
  135. bottom: 0px;
  136. left: 0px;
  137. right: 0px;
  138. }
  139. .el-menu-vertical-demo:not(.el-menu--collapse) {
  140. width: 200px;
  141. min-height: 400px;
  142. }
  143. .layout aside .logo .router {
  144. display: flex;
  145. justify-content: space-evenly;
  146. align-items: center;
  147. animation-duration: 0.1s;
  148. overflow: hidden;
  149. text-decoration: none;
  150. padding-left: 1px;
  151. position: relative;
  152. left: 2px;
  153. }
  154. .layout aside .logo .router h1 {
  155. margin-left: 10px;
  156. color: aliceblue;
  157. overflow: hidden;
  158. }
  159. .layout aside .logo .router img {
  160. padding-left: 5px;
  161. width: 48px;
  162. height: 48px;
  163. }
  164. </style>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post