router的动态切换$route.meta.title

router的动态切换$route.meta.title

这里主要是 meta 属性下面设置一个自定义的键值 title
这个技术可以用来做什么?
在头部nav切换选中效果,在二级页面或者三级页面也具有此切换选中的效果。
在layout中
template中 使用v-for渲染页面

      <div
        v-for="(item,index) in titleList"
        :key="item.name"
        class="tab-list-item"
        @click="changeActiveIndex(item,index)"
      >
        <span class="tab-list-span" :style="{color:(item.name==$route.meta.title?'white':'')}">
          <svg-icon :icon-class='item.iconName'></svg-icon>
          {{ item.name }}
        </span>
        <img
          v-if="item.name==$route.meta.title"
          src="../../assets/img/templeChoose.png"
          :style="item.style"
          class="itembg"
          alt=""
        >
      </div>

js中的数据

                titleList: [
                    {
                      name: '可视化指挥中心',
                        style: {
                             width: '175px',
                          top:0,
                          marginLeft:'8px',
                          marginTop: '8px',
                          height: '35px',

                        },
                        iconName: 'tar1',
                        route: '/newView'
                    },
                    {
                      name: '数据综合治理中心',
                        style: {
                             width: '190px',
                          top:0,
                          marginLeft:'9px',
                          marginTop: '8px',
                          height: '35px',
                        },
                      iconName: 'tar2',
                        route: '/newDate',
                    },
                    {
                      name: '可视化专题图',
                        style: {
                             width: '150px',
                          top:0,
                          marginLeft:'15px',
                          marginTop: '8px',
                          height: '35px',
                        },
                        iconName: 'tar3',
                        route: '/newDraw'
                    },
                    {
                      name: '大数据统计分析',
                        style: {
                             width: '165px',
                          top:0,
                          marginLeft:'14px',
                          marginTop: '8px',
                          height: '35px',
                        },
                        iconName: 'tar4',
                        route: '/newTotal'
                    },
                    {
                      name: '数据上报系统',
                        style: {
                             width: '155px',
                          top:0,
                          marginLeft:'14px',
                          marginTop: '8px',
                          height: '35px',
                        },
                        iconName: 'tar5',
                        route: '/newUp'
                    },
                    {
                      name: '指挥中心',
                        style: {
                             width: '110px',
                          top:0,
                          marginLeft:'17px',
                          marginTop: '8px',
                          height: '35px',
                        },
                        iconName: 'tar6',
                        route: '/newF'
                    }
                ],
                activeIndex: '指挥中心'
            }
        }

router中的路由格式

      { //人员信息管理库
        path: "/newDate/PeopelKu",
        name: 'PeopelKu',
        component: () => import('@/views/newDate/PeopelKu'),
        meta: {
          title: '数据综合治理中心',
          showSearch: false,
          templeChoose: false
        },
      },

参考地址:https://blog.csdn.net/qq_36410795/article/details/89792782

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值