<template>
  <div class="breadcrumb-wrap">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <span class="site-accountability iconfont iconweizhi" style="padding-left: 10px;"><span>当前位置：</span></span>
      <el-breadcrumb-item v-for="(item,index)  in levelList" :key="index" v-if="item.meta.title">{{item.meta.title}}</el-breadcrumb-item>
       <!-- && index !==1  -->
    </el-breadcrumb>
  </div>
</template>

<script>
export default {
  name: "breadcrumb",
  created() {
    this.getBreadcrumb();
  },
  data() {
    return {
      levelList: null
    };
  },
  watch: {
    $route() {
      this.getBreadcrumb();
    }
  },
  methods: {
    getBreadcrumb() {
      let matched = this.$route.matched.filter(item => item.name);
      const first = matched[0];
      //  && first.name !== "dashboard"
      if (first) {
        // matched = [
        //   { path: "", meta: { title: "区长责任制" } }
        // ].concat(matched);
        matched = matched
      }
      this.levelList = matched;
      console.log(this.$route.matched,'===========')
      console.log(this.levelList,'--------------------------')
    }
  }
};
</script>
