<template>
  <div id="native">
    <el-row>
      <el-col :span="24">
        <el-menu :default-active="activeIndex2" class="el-menu-demo" mode="horizontal"
               background-color="#336699" text-color="#fff" active-text-color="#fff" style="height:40px;" :router="true">
        <!-- 循环菜单↓ -->
        <template v-for="(item, index) in menu">
          <el-submenu :index="`${index}`" :key="index" v-if="item.type !== 'url' && item.type !== 'content'">
            <!-- 输出一级栏目↓ -->
            <template slot="title">
              {{ item.title }}
            </template>
            <template v-for="(sub, subIndex) in item.children">
              <el-submenu :index="`${index}-${subIndex}`" :key="subIndex+'sub'" v-if="sub.children">
                <template slot="title">
                  {{ sub.title }}
                </template>
                <template v-for="(thr,thrIndex) in sub.children">
                  <el-menu-item :index="thr.path" :key="thrIndex+'thr'" v-if="thr.type !== 'url'">{{ thr.title }}</el-menu-item>
                  <el-menu-item :index="``" :key="thrIndex+'thr'" @click="turnTo(thr.url)" v-else> {{ thr.title }}</el-menu-item>
                </template>
              </el-submenu>
              <el-menu-item :index="sub.path" :key="subIndex+'sub'" v-else-if="sub.type === 'content'||sub.type==='column'">{{ sub.title }}</el-menu-item>
              <el-menu-item :index="`${index}-${subIndex}`" :key="subIndex+'sub'" @click="turnTo(sub.url)" v-else> {{ sub.title }}</el-menu-item>
            </template>
          </el-submenu>
          <!-- 一级栏目非常规栏目情况 -->
          <el-menu-item v-else-if="item.type === 'content'" :index="item.path" :key="index">{{ item.title }}</el-menu-item>
          <el-menu-item v-else :index="``" :key="index" @click="turnTo(item.url)">{{ item.title }}</el-menu-item>
          <!-- 输出一级栏目结束↑ -->
        </template>
        <!-- 循环菜单结束↑ -->
      </el-menu>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapActions, mapState,mapMutations } from 'vuex';
export default {
  name: 'native',
  props: {},
  components: {},
  data: () => ({
    activeIndex2: '',
  }),
  created() {},
  computed: {
    ...mapState(['menu']),
  },
  methods: {
    turnTo(url) {
      window.open(url);
    },
  },
};
</script>

<style lang="less" scoped>
.el-menu--horizontal > .el-menu-item {
  height: 40px;
  line-height: 40px;
}
/deep/.el-menu--horizontal > .el-submenu .el-submenu__title {
  height: 40px;
  line-height: 40px;
}
</style>
