问题:
1.当我们在使用路由时,如果有导航条此时,我们在url地址栏目改变路由地址,此时路由内容更改但,导航条样式没有随着改动
2.当页面刷新时,url导航地址栏的路由和当前页面显示的不一致
解决:
1.通过watch监听路由地址的改变
2.使用钩子函数,改变路由
export default {name: 'App',data(){return {msg:'App.vue',currentRouter:'/'}},methods:{},watch:{'$route':function(to,from){this.currentRouter=to.path;}},beforeMount(){this.currentRouter=this.$route.path;}}
**: 上面的代码,要放在跟路由页面中