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

59 lines
1.2 KiB

  1. <template>
  2. <div class="top-menu">
  3. <el-menu
  4. :default-active="activeIndex"
  5. mode="horizontal"
  6. text-color="#333">
  7. <template v-for="(item,index) in items">
  8. <el-menu-item
  9. :index="item.parentId+''"
  10. :key="index"
  11. @click.native="openMenu(item)">
  12. <template slot="title">
  13. <i :class="item.icon"/>
  14. <span>{{ item.label }}</span>
  15. </template>
  16. </el-menu-item>
  17. </template>
  18. </el-menu>
  19. </div>
  20. </template>
  21. <script>
  22. import { mapGetters } from 'vuex'
  23. export default {
  24. name: 'TopMenu',
  25. inject: ["Index"],
  26. data() {
  27. return {
  28. activeIndex: '0',
  29. items: []
  30. }
  31. },
  32. created() {
  33. // 显示顶部菜单
  34. this.getTopMenu()
  35. // 用户权限加载
  36. this.getUserInfo()
  37. console.log('this.getUserInfo()')
  38. },
  39. computed: {
  40. ...mapGetters(['menu'])
  41. },
  42. methods: {
  43. getTopMenu() {
  44. this.$store.dispatch("GetTopMenu").then(res => {
  45. this.items = res;
  46. });
  47. },
  48. openMenu(item) {
  49. this.Index.openMenu(item)
  50. },
  51. getUserInfo() {
  52. // 更新sessionStore 权限信息
  53. this.$store.dispatch('GetUserInfo')
  54. }
  55. }
  56. }
  57. </script>