当前位置:   article > 正文

【在线OJ】Vue创建OJ管理系统

【在线OJ】Vue创建OJ管理系统

一、创建项目

vue ui命令创建项目

项目创建完成后来到项目 

二、导航栏

首先创建一个根页面,让他展示在页面上

创建之后来到路由配置界面 

然后安装ElementUI,来到官网找到导航栏

 

复制代码后粘贴到刚才创建的vue文件里,启动项目,调整样式 

  1. <template>
  2. <div>
  3. <div style="display: flex; width: 100%; height: 100vh">
  4. <div style="height: 100%">
  5. <!-- 后序默认修改为组件-->
  6. <el-menu router style="height: 100%; " :default-active="activeIndex" class="el-menu-vertical-demo" @open="handleOpen"
  7. @close="handleClose" :collapse="isCollapse">
  8. <el-menu-item index="data">
  9. <i class="el-icon-s-operation"></i>
  10. <span slot="title">数据展示</span>
  11. </el-menu-item>
  12. <el-submenu index="users">
  13. <template slot="title">
  14. <i class="el-icon-s-custom"></i>
  15. <span slot="title">用户管理</span>
  16. </template>
  17. <el-menu-item-group>
  18. <el-menu-item index="users">用户列表</el-menu-item>
  19. <el-menu-item index="users2">添加用户</el-menu-item>
  20. </el-menu-item-group>
  21. </el-submenu>
  22. <el-submenu index="forum">
  23. <template slot="title">
  24. <i class="el-icon-picture"></i>
  25. <span slot="title">论坛管理</span>
  26. </template>
  27. <el-menu-item-group>
  28. <el-menu-item index="forum">文章列表</el-menu-item>
  29. <el-menu-item index="forum2">评论管理</el-menu-item>
  30. </el-menu-item-group>
  31. </el-submenu>
  32. <el-submenu index="problems">
  33. <template slot="title">
  34. <i class="el-icon-s-order"></i>
  35. <span slot="title">题库管理</span>
  36. </template>
  37. <el-menu-item-group>
  38. <el-menu-item index="problems">题目列表</el-menu-item>
  39. <el-menu-item index="problems2">题目添加</el-menu-item>
  40. </el-menu-item-group>
  41. </el-submenu>
  42. <el-submenu index="competition">
  43. <template slot="title">
  44. <i class="el-icon-s-opportunity"></i>
  45. <span slot="title">比赛管理</span>
  46. </template>
  47. <el-menu-item-group>
  48. <el-menu-item index="competition">比赛数据</el-menu-item>
  49. <el-menu-item index="competition2">添加比赛</el-menu-item>
  50. </el-menu-item-group>
  51. </el-submenu>
  52. </el-menu>
  53. </div>
  54. <div style="height: 100%; width: 175.4vh">
  55. <!-- header-->
  56. <div v-if="!isCollapse" style="box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); width: 175.4vh; height: 4.8vh">
  57. <div style="float: left; height: 100%; font-size: medium; margin-top: 0.5%; margin-left: 0.5%">
  58. <i v-if="!isCollapse" class="el-icon-s-fold" @click="isCollapse = !isCollapse"></i>
  59. <i v-else class="el-icon-s-unfold" @click="isCollapse = !isCollapse"></i>
  60. </div>
  61. <div style="float: left; margin-left: 3vh; margin-top: 0.6vh;color: #409EFF">Online OJ Admin</div>
  62. <div style="height: 4.8vh; font-size: small">
  63. <!-- <el-dropdown style="font-size: xx-small">-->
  64. <el-avatar size="small" style="font-size: 5vh; margin-left: 140vh; margin-bottom: 2%"
  65. src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></el-avatar>
  66. <!-- </el-dropdown>-->
  67. </div>
  68. </div>
  69. <!-- header副本-->
  70. <div v-else style="box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); width: 193.5vh; height: 4.8vh">
  71. <div style="float: left; height: 100%; font-size: medium; margin-top: 0.5%; margin-left: 0.5%">
  72. <i v-if="!isCollapse" class="el-icon-s-fold" @click="isCollapse = !isCollapse"></i>
  73. <i v-else class="el-icon-s-unfold" @click="isCollapse = !isCollapse"></i>
  74. </div>
  75. <div style="float: left; margin-left: 3vh; margin-top: 0.6vh; color: #409EFF">Online OJ Adminw</div>
  76. <div style="height: 4.8vh; font-size: small; margin-bottom: 2%">
  77. <!-- <el-dropdown style="font-size: xx-small">-->
  78. <el-avatar size="small" style="font-size: 5vh; margin-left: 160vh; margin-bottom: 2%"
  79. src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></el-avatar>
  80. <!-- </el-dropdown>-->
  81. </div>
  82. </div>
  83. <div>
  84. <router-view></router-view>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </template>
  90. <style>
  91. .el-menu-vertical-demo:not(.el-menu--collapse) {
  92. width: 200px;
  93. min-height: 400px;
  94. }
  95. </style>
  96. <script>
  97. export default {
  98. data() {
  99. return {
  100. isCollapse: true,
  101. activeIndex: 'data',
  102. // 上面为组件相关
  103. };
  104. },
  105. methods: {
  106. // 组件相关
  107. handleOpen(key, keyPath) {
  108. console.log(key, keyPath);
  109. this.activeIndex = key
  110. },
  111. handleClose(key, keyPath) {
  112. console.log(key, keyPath);
  113. this.activeIndex = key
  114. }
  115. }
  116. }
  117. </script>

 

 

三、路由配置

根据需求如:XX管理,XX管理配置导航栏后,创建对应的组件在index.js中进行路由配置

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/568234
推荐阅读
相关标签
  

闽ICP备14008679号