router/index.js
router.beforeEach((to,from,next)=>{
localStorage.setItem("currentPathName",to.name)//设置存储,取得路径名称
next();//使用
})
Header.vue
<el-breadcrumb-item>{{currentPathName}}</el-breadcrumb-item> //渲染路径
watch:{ //监听路由跳转
'$route' :function ()
{
this.currentPathName=localStorage.getItem("currentPathName")//获取路径
},
},
效果