侧边栏壁纸
  • 累计撰写 47 篇文章
  • 累计创建 16 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

vue更改浏览器title以及二级目录更改title

七月流火
2022-10-10 / 0 评论 / 0 点赞 / 294 阅读 / 0 字 / 正在检测是否收录...

1.更改浏览器文案 在main.js增加如下代码

router.beforeEach((to, from, next) => {
  if (to.query.titles) {
    to.meta.title = to.query.titles //获取从上个页面传过来的name再进行修改
  }
  next()
})

2.更改二级标签
原页面更改

    setTitle() {
        let routerInfo = {
            name: "xxx",
            path: "/url",

        }
        this.$store.dispatch("tagsView/delView", routerInfo);
    },
    superviseExcetion(row) {
      this.setTitle();
      this.$router.push({path:"/url",query:{titleType:1}});
    },

跳转后页面

    created() {
      let titleType = this.$route.query.titleType
      this.$route.meta.title = null
      if (titleType == 1) {
        this.$route.meta.title = '标题一'
      }else{
        this.$route.meta.title = '标题二'
      }
    },

0
VUE

评论区