1.0
明梦爽
2022-01-10 3fbb5e3166522734fd5407bcdf76c384d40e9dfa
src/components/Home.vue
@@ -11,21 +11,9 @@
    </el-header>
    <!-- 主页导航栏 -->
    <el-row>
      <el-menu
        mode="horizontal"
        background-color="rgb(64, 112, 186)"
        text-color="white"
        class="menu"
        active-text-color="#000000"
        :default-active="activeIndex"
        @select="handleSelect"
      >
        <el-menu-item
          :key="index"
          v-for="(item, index) in menuList"
          :index="item.index"
        >
          {{ item.name }}
      <el-menu mode="horizontal" background-color="rgb(64, 112, 186)" text-color="white" class="menu" active-text-color="#000000" :default-active="activeIndex" @select="handleSelect">
        <el-menu-item :key="index" v-for="(item, index) in menuList" :index="(item.id).toString()">
          {{ item.contypeName }}
        </el-menu-item>
      </el-menu>
    </el-row>
@@ -40,37 +28,67 @@
</template>
<script>
import {getNavList} from '../api/api'
export default {
  name: '',
  data() {
    return {
      activeIndex: 'index',
      menuList: [
        { index: 'index', name: '首页' },
        { index: 'introduce', name: '科协概况' },
        { index: 'zhengce', name: '政策法规' },
        { index: 'keXieXiangMu', name: '科协项目' },
        { index: 'xueShuJiaoLiu', name: '学术交流' },
        { index: 'banShiZhiNan', name: '办事指南' },
        { index: 'kePu', name: '科普风采' },
        { index: 'xueXiaoShouYe', name: '学校首页' },
        { index: 'telephone', name: '联系我们' }
      ]
      activeIndex: '1',
      menuList: [{contypeName: '首页',id: 1},{contypeName: '科协概况',id: 2},{contypeName: '政策法规',id: 3},{contypeName: '科协项目',id: 4},
      {contypeName: '学术交流',id: 5},{contypeName: '办事指南',id: 6},{contypeName: '科普风采',id: 7},{contypeName: '学校首页',id: 8},
      {contypeName: '联系我们',id: 9}],
    }
  },
  created() {},
  created() {
    // this.getNavArr();
  },
  mounted() {},
  watch: {},
  methods: {
    // //获取导航栏
    // getNavArr(){
    //   const data ={};
    //   getNavList(data).then(res => {
    //     console.log('res', res)
    //     if(res.code == 200){
    //       this.menuList = res.data
    //     }
    //   }).catch(err => {
    //     console.log('err', err)
    //   })
    // },
    formatterTitle(t){
      switch(t){
        case '1':
          return 'index'
        case '2':
          return 'introduce'
        case '3':
          return 'zhengce'
        case '4':
          return 'keXieXiangMu'
        case '5':
          return 'xueShuJiaoLiu'
        case '6':
          return 'banShiZhiNan'
        case '7':
          return 'kePuFengCai'
        case '8':
          return 'xueXiaoShouYe'
        case '9':
          return 'telephone'
      }
    },
    handleSelect(key, keyPath) {
      console.log(key, keyPath)
      if (key == 'xueXiaoShouYe') {
        window.location.href = 'https://www.pdsu.edu.cn/#'
      if (key == '8') {
        window.open('https://www.pdsu.edu.cn/#')
      } else {
        this.$router.push({
          path: '/home/' + key,
          path: '/home/' + this.formatterTitle(key),
          query: {
            title: key
            title: this.formatterTitle(key),
            id:key
          }
        })
      }
@@ -88,7 +106,7 @@
}
.el-header {
  height: 120px !important;
  padding: 0 40px;
  padding: 0 80px 0 120px;
  overflow: hidden;
  display: flex;
  justify-content: space-between;