vue面包屑动态显示
时间: 2023-09-09 15:11:00 浏览: 73
要实现Vue面包屑动态显示,可以按照以下步骤进行操作:
1. 首先,在`src`文件夹下的`components`文件夹中新建一个名为`Breadcrumb.vue`的文件。[2]
2. 在`Breadcrumb.vue`文件中,将以下代码复制粘贴进去:
```html
<template>
<div>
<el-breadcrumb separator="/">
<el-breadcrumb-item v-for="(v, i) in breadList" :key="i" :to="v.meta.path">
{{ v.meta.title }}
</el-breadcrumb-item>
</el-breadcrumb>
</div>
</template>
<script>
export default {
data() {
return {
breadList: [],
};
},
watch: {
$route() {
this.getBreadcrumb();
},
},
methods: {
isHome(route) {
return route.name === "home";
},
getBreadcrumb() {
let matched = this.$route.matched;
if (!this.isHome(matched<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Vue实现动态面包屑](https://blog.csdn.net/weixin_51497206/article/details/118599173)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [vue实现动态面包屑](https://blog.csdn.net/weixin_48398799/article/details/119981153)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文