route.js的配置
{
path:"/parent",
name: 'parent',
component : () => import('@/views/parent.vue'),
meta: { title: 'parent',path:'/parent' },
children:[
{
path:'child',
component: () => import ('@/views/child.vue'),
meta: { title: 'child'},
}
]
},
组件:
<Breadcrumb style="padding: 20px 0 0 20px;background: #fff;">
<span class="goback" title="返回上一页" onclick="history.back()">
<Icon type="md-arrow-back" size="16" />
</span>
当前位置:
<template v-for="(item, index) in breadCrumbList">
<BreadcrumbItem
:key="index"
v-if="item.title"
:to="{ path: item.path }"
>{{ item.title }}
</BreadcrumbItem>
</template>
</Breadcrumb>
<script>
export default {
data() {
return {
breadCrumbList: [],
};
},
watch: {
$route(to) {
console.log(this.$route)
console.log(this.$route.matched)
this.breadCrumbList = this.$route.matched
.map((item) => item.meta)
console.log(this.breadCrumbList)
},
},
};
</script>