native.vue 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div id="native">
  3. <el-row>
  4. <el-menu :default-active="activeIndex2" class="el-menu-demo" mode="horizontal" @select="handleSelect"
  5. background-color="rgba(0,0,0,0.4)" text-color="#fff" active-text-color="#fff" :router="true">
  6. <template v-for="(item, index) in menu">
  7. <el-submenu :index="`${index}`" :key="index" v-if="item.type !== 'url' && item.type !== 'content'">
  8. <!-- 输出一级栏目↓ -->
  9. <template slot="title">
  10. {{ item.title }}
  11. </template>
  12. <template v-for="(sub, subIndex) in item.children">
  13. <template v-if="sub.children">
  14. <template v-for="(thr) in sub.children">
  15. <el-menu-item :index="thr.path" :key="thr.id" v-if="thr.type !== 'url'" style="float: left;height:60px;line-height:60px;font-size:20px;" class="hover">{{ thr.title }}</el-menu-item>
  16. <el-menu-item :index="``" :key="thr.id" @click="turnTo(thr.url)" v-else style="float: left;height:60px;line-height:60px;font-size:20px;" class="hover"> {{ thr.title }}</el-menu-item>
  17. </template>
  18. </template>
  19. <el-menu-item :index="sub.path" :key="subIndex+'sub'" v-else-if="sub.type === 'content'||sub.type==='column'" style="float: left;height:60px;line-height:60px;font-size:20px;" class="hover">{{ sub.title }}</el-menu-item>
  20. <el-menu-item :index="`${index}-${subIndex}`" :key="subIndex+'sub'" @click="turnTo(sub.url)" v-else style="float: left;height:60px;line-height:60px;font-size:20px;" class="hover"> {{ sub.title }}</el-menu-item>
  21. </template>
  22. </el-submenu>
  23. <!-- 一级栏目非常规栏目情况 -->
  24. <el-menu-item v-else-if="item.type === 'content'" :index="item.path" :key="index" style="float: left;height:60px;line-height:60px;font-size:20px;" class="hover">{{ item.title }}</el-menu-item>
  25. <el-menu-item v-else :index="``" :key="index" @click="turnTo(item.url)" style="float: left;height:60px;line-height:60px;font-size:20px;" class="hover">{{ item.title }}</el-menu-item>
  26. <!-- 输出一级栏目结束↑ -->
  27. </template>
  28. </el-menu>
  29. </el-row>
  30. </div>
  31. </template>
  32. <script>
  33. import { mapActions, mapState, mapMutations } from 'vuex';
  34. export default {
  35. name: 'native',
  36. props: {},
  37. components: {},
  38. data: () => ({
  39. activeIndex2: '1'
  40. }),
  41. created() { },
  42. computed: {
  43. ...mapState(['menu']),
  44. },
  45. methods: {
  46. turnTo(url) {
  47. window.open(url);
  48. },
  49. handleSelect(key, keyPath) {
  50. // console.log(key, keyPath);
  51. }
  52. },
  53. };
  54. </script>
  55. <style lang="less" scoped>
  56. .hover:hover {
  57. background-color: #215299 !important;
  58. }
  59. /deep/.el-submenu__title {
  60. font-size: 20px;
  61. }
  62. /deep/.el-submenu__title:hover {
  63. background-color: #215299 !important;
  64. }
  65. /deep/.el-menu--horizontal > .el-submenu .el-submenu__icon-arrow {
  66. display: none;
  67. }
  68. </style>