You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

TopMenu.vue 2.0 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div class="container ui" style="padding:0 75px;">
  3. <div class="menu">
  4. <div class="menu-l">
  5. <div class="menu-item" v-for="(item, index) in list" :key="index" :class="focusIndex == index ? 'focused' : ''"
  6. @click="changeMenu(item, index)">
  7. {{ item.title }}
  8. </div>
  9. </div>
  10. <div class="menu-r"></div>
  11. </div>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. name: "TopMenu",
  17. props: {
  18. menu: { type: Number, default: -1 },
  19. },
  20. components: {},
  21. data() {
  22. return {
  23. focusIndex: 0,
  24. list: [{
  25. key: 'tech_view',
  26. title: '按科技项目查看',
  27. url: '/tech/tech_view',
  28. }, {
  29. key: 'repo_view',
  30. title: '按项目成果查看',
  31. url: '/tech/repo_view',
  32. },/* {
  33. key: '',
  34. title: '我申请的项目',
  35. url: '',
  36. }*/],
  37. };
  38. },
  39. methods: {
  40. changeMenu(item, index) {
  41. this.focusIndex = index;
  42. window.location.href = item.url;
  43. }
  44. },
  45. beforeMount() {
  46. this.focusIndex = this.menu;
  47. },
  48. mounted() { },
  49. };
  50. </script>
  51. <style scoped lang="less">
  52. .menu {
  53. display: flex;
  54. align-items: center;
  55. justify-content: space-between;
  56. .menu-l {
  57. display: flex;
  58. align-items: center;
  59. justify-content: flex-start;
  60. }
  61. .menu-r {
  62. display: flex;
  63. align-items: center;
  64. justify-content: flex-end;
  65. }
  66. .menu-item {
  67. display: flex;
  68. border-color: rgb(187, 187, 187);
  69. border-width: 1px 1px 0px 0px;
  70. border-style: solid;
  71. font-size: 14px;
  72. line-height: 20px;
  73. color: rgba(255, 255, 255, 0.7);
  74. align-items: center;
  75. text-align: center;
  76. justify-content: center;
  77. background: rgba(104, 50, 165, 0.2);
  78. height: 40px;
  79. width: 178px;
  80. cursor: pointer;
  81. &:first-child {
  82. border-left-width: 1px;
  83. }
  84. &.focused {
  85. color: rgb(255, 255, 255);
  86. background: rgba(249, 249, 249, 0.2);
  87. }
  88. }
  89. }
  90. </style>