index.vue 1.41 KB
<template>
  <a-layout style="height:100vh">
    <a-layout-header class="nav-header">
      <Header />
    </a-layout-header>
    <a-layout>
      <SiderMenu />
      <a-layout style="padding: 0 24px 24px">
        <a-breadcrumb style="margin: 16px 0">
          <a-breadcrumb-item v-for="(item,key) in breadList" :key="key">{{item}}</a-breadcrumb-item>
        </a-breadcrumb>
        <a-layout-content :style="{ background: '#fff', margin: 0, minHeight: '280px' }">
          <router-view></router-view>
        </a-layout-content>
      </a-layout>
    </a-layout>
  </a-layout>
</template>
<script>
import Header from './components/Header'
import SiderMenu from './components/SiderMenu'
import breadTextConfig from '@/utils/breadcrumb'
export default {
  name: 'DefaultLayout',
  components: {
    Header,
    SiderMenu
  },
  watch: {
    '$route.path': function (val) {
      this.getBreadCrumb(val)
    }
  },
  data() {
    return {
      breadList: []
    };
  },
  mounted() {
    const currentPath = this.$route.path
    this.getBreadCrumb(currentPath)
    // console.log('breadList', this.breadList)
  },
  methods: {
    getBreadCrumb(currentPath) {
      for (let i in breadTextConfig) {
        if (i == currentPath) {
          this.breadList = breadTextConfig[i]
        }
      }
    }
  }
};
</script>

<style>
.nav-header {
  padding: 0 !important;
  background: #fff !important;
}
.left-sider {
  width: 200px;
}
</style>