Vue使用router-link作为导航栏跳转遇到的Bug
遇到的问题:点击导航按钮时,第一次点击没有选择状态,第二次点击需要选择状态。测试过程:控制台打印获取缓存,在控制台打印导航栏索引,并初始化为undefined。第一次点击控制台打印,但是获取到索引缓存后,代码自动重复了一次打印,index的值返回undefined,状态未选中,点击第二次控制台打印,获取索引缓存,代码不执行重复打印,选择状态解决问题:只需添加router-link-activestyle.router-link-active{background:#848484;}代码:在ronter-link中添加exact属性即可解决主页已默认激活{{item.title}}{{item.标题}}
#head-nava用于在有多个router-links时定位#head-nava.router-link-active{background:#0172ea;}参考原文地址:https://www.jianshu.com/p/eca...https://blog.csdn.net/mylover...https://www.cnblogs。com/lisiy...https://blog.csdn.net/version...https://blog.csdn.net/x_xiNan...https://www.jianshu.com/p/d9a...https://segmentfault.com/q/10...https://blog.csdn.net/qq_4223...