zoukankan      html  css  js  c++  java
  • 3.active-class 是哪个组件的属性?

    active-class属于Vue哪一个modules,有什么作用

    active-class 属于vue-router的样式方法
        当routerlink标签被点击时将会应用这个样式
     
    使用有两种方法
    routerLink标签内使用
    
    <router-link to='/' active-class="active" >首页</router-link>
    

    在路由js文件,配置active-class

    <script>
        const router = new VueRouter({
            routes,
            linkActiveClass: 'active'
        });
    </script>
    <script>
        const router = new VueRouter({
            routes,
            linkActiveClass: 'active'
        });
    </script>
    

    在使用时会有一个Bug

    首页的active会一直被应用
    解决办法
    为了解决上面的问题,还需加入一个属性exact,类似也有两种方式:
    在router-link中写入exact

        <router-link to='/' active-class="active" exact>首页</router-link>
    

    在路由js文件,配置active-class

    <script>
        const router = new VueRouter({
            routes,
            linkExactActiveClass: 'active'
        });
    </script>


    作者:w晚风
    链接:https://www.jianshu.com/p/302a712f3ea8
    来源:简书
    著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
  • 相关阅读:
    登陆的一个大概流程
    过滤器实现编码过滤处理
    注册的一个大概流程
    lstm clip
    gemm c++
    lstm的debug模式下编译不行貌似
    caffe编译关于imread问题的解决
    c++ 走向高级之日积月累
    c++ 线程
    InitGoogleLogging坑爹
  • 原文地址:https://www.cnblogs.com/dream111/p/13493500.html
Copyright © 2011-2022 走看看