Create a breadcrumb navigation bar through elementUI in vue2.0

亚连
Release: 2018-06-05 16:05:12
Original
4548 people have browsed it

This article mainly explains the process of making a breadcrumb navigation bar with vue2.0 elementUI in detail. Friends who are interested in this can learn it.

Main.js

var routeList = []; router.beforeEach((to, from, next) => { var index = -1; for(var i = 0; i < routeList.length; i++) { if(routeList[i].name == to.name) { index = i; break; } } if (index !== -1) { //如果存在路由列表,则把之后的路由都删掉 routeList.splice(index + 1, routeList.length - index - 1); } else if(to.name != '登录'){ routeList.push({"name":to.name,"path":to.fullPath}); } to.meta.routeList = routeList; next() });
Copy after login

2. Use watch or beforeRouteEnter in the component to be used

 
Copy after login

.

It should be noted that beforeRouteEnter cannot access this at this time.

const Foo = { template: `...`, beforeRouteEnter (to, from, next) { // 在渲染该组件的对应路由被 confirm 前调用 // 不!能!获取组件实例 `this` // 因为当守卫执行前,组件实例还没被创建 }, beforeRouteUpdate (to, from, next) { // 在当前路由改变,但是该组件被复用时调用 // 举例来说,对于一个带有动态参数的路径 /foo/:id,在 /foo/1 和 /foo/2 之间跳转的时候, // 由于会渲染同样的 Foo 组件,因此组件实例会被复用。而这个钩子就会在这个情况下被调用。 // 可以访问组件实例 `this` }, beforeRouteLeave (to, from, next) { // 导航离开该组件的对应路由时调用 // 可以访问组件实例 `this` } }
Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Use v-for to implement the method of assigning values to src attributes through Vue (detailed tutorial)

Through vue v-for implements the method of loading local static images (detailed tutorial)

How to solve the problem of red and warning when using v-for in vue (detailed tutorial)

The above is the detailed content of Create a breadcrumb navigation bar through elementUI in vue2.0. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!