Skip to content

Commit

Permalink
🌸Bug fix.When router link to other page, the selected tabbar error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Geek-James committed Nov 16, 2019
1 parent 77a1539 commit f1d7e93
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions src/views/dashboard/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Motto: 求知若渴,虚心若愚
* @Github: https://github.com/Geek-James/ddBuy
* @掘金: https://juejin.im/user/5c4ebc72e51d4511dc7306ce
* @LastEditTime: 2019-11-10 14:59:50
* @LastEditTime: 2019-11-16 12:39:22
* @Description: 项目根入口
* @FilePath: /ddBuy/src/views/dashboard/Dashboard.vue
-->
Expand Down Expand Up @@ -39,27 +39,32 @@ export default {
name: "DashBoard",
mounted () {
},
created () {
//通过路由跳转绑定Tabbar的选中
switch (this.$route.name) {
case 'home':
this.active = 0;
break;
case 'category':
this.active = 1;
break;
case 'eat':
this.active = 2;
break;
case 'cart':
this.active = 3;
break;
case 'mine':
this.active = 4;
break;
default:
break;
}
watch: {
// 监听路由变化,保证路由跳转Tabbar选中正常
$route: {
handler (val, oldval) {
switch (val.name) {
case "home":
this.active = 0;
break;
case "category":
this.active = 1;
break;
case "eat":
this.active = 2;
break;
case "cart":
this.active = 3;
break;
case "mine":
this.active = 4;
break;
default:
break;
}
}
},
deep: true
},
data () {
return {
Expand Down

0 comments on commit f1d7e93

Please sign in to comment.