zoukankan      html  css  js  c++  java
  • 固定底部菜单栏,点击跳转到指定路由

    效果图

           

    html代码

      <div class="lay-item" v-for="(item,index) in routerList" @click.nactive="changeItem(index)">
          <router-link :to="item.url" tag="span" :class="[active==index?'item-active':'']">{{item.tag}}</router-link>
        </div>

    javascript代码:

    data(){
          return{
            active:0,
            routerList:[
              {id:0,tag:"背单词",url:"/index"},
              {id:1,tag:"阅读",url:"/read"},
              {id:2,tag:"听力",url:"/listen"},
              {id:3,tag:"我",url:"/me"},
            ]
          },
      methods:{
          changeItem(index){
         this.routerList.forEach((item,i)=>{
          if(index==i){
          this.active=index

          this.$router.push(item.url)
          }
         })

         }

        },

       created(){
         const path=(this.$router.history.current.path)
          this.routerList.forEach((item,index)=>{
            if(item.url==path){
              this.active=index
            }
          })
       }
  • 相关阅读:
    BZOJ 2326 数学作业
    BZOJ 4448 情报传递
    BZOJ 4443 小凸玩矩阵
    BZOJ 1852 最长不下降序列
    BZOJ 4373 算术天才⑨与等差数列
    68285
    65656556
    D. Points in rectangle
    恐怖的怪物
    再战斐波那契
  • 原文地址:https://www.cnblogs.com/shanchui/p/12836374.html
Copyright © 2011-2022 走看看