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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. if (this.focusIndex == index) return;
  42. this.focusIndex = index;
  43. window.location.href = item.url;
  44. }
  45. },
  46. beforeMount() {
  47. this.focusIndex = this.menu;
  48. },
  49. mounted() { },
  50. };
  51. </script>
  52. <style scoped lang="less">
  53. .menu {
  54. display: flex;
  55. align-items: center;
  56. justify-content: space-between;
  57. .menu-l {
  58. display: flex;
  59. align-items: center;
  60. justify-content: flex-start;
  61. }
  62. .menu-r {
  63. display: flex;
  64. align-items: center;
  65. justify-content: flex-end;
  66. }
  67. .menu-item {
  68. display: flex;
  69. border-color: rgb(187, 187, 187);
  70. border-width: 1px 1px 0px 0px;
  71. border-style: solid;
  72. font-size: 14px;
  73. line-height: 20px;
  74. color: rgba(255, 255, 255, 0.7);
  75. align-items: center;
  76. text-align: center;
  77. justify-content: center;
  78. background: rgba(104, 50, 165, 0.2);
  79. height: 40px;
  80. width: 178px;
  81. cursor: pointer;
  82. &:first-child {
  83. border-left-width: 1px;
  84. }
  85. &.focused {
  86. cursor: default;
  87. color: rgb(255, 255, 255);
  88. background: rgba(249, 249, 249, 0.2);
  89. }
  90. }
  91. }
  92. </style>