• vue修改浏览器的标题title


    实现思路很简单:就是利用路由的导购守卫beforeEach在每次页面跳转前更改对应的title

    第一步:首先在route里面给每个路由加上meta属性

    第二步:在main.js里面加上导航守卫

    router.beforeEach((to, from, next) => {

        window.document.title = to.meta.title == undefined?'默认标题':to.meta.title

        if (to.meta.requireAuth) {

            let token = Cookies.get('access_token');

            let anonymous = Cookies.get('user_name');

            if (token) {

                

                    next({

                        path: '/login',

                        query: {

                            redirect: to.fullPath

                        }

                    })

              

            }

        }

        next();

    })

  • 相关阅读:
    植物:柏树
    植物:水杉
    植物:珙桐
    植物:桫椤
    汉语-成语:悠闲自在
    植物:孑遗植物
    汉语-词语:孑遗
    汉语-词语:调味品
    调味品:酱油
    netstat 命令详解
  • 原文地址:https://www.cnblogs.com/PoisonousMushrooms/p/12107209.html
Copyright © 2020-2023  润新知