Browse Source

Select menu item on route change and load

sbkwgh 8 năm trước cách đây
mục cha
commit
03ff12e0f7
1 tập tin đã thay đổi với 8 bổ sung1 xóa
  1. 8 1
      src/components/routes/Admin.vue

+ 8 - 1
src/components/routes/Admin.vue

@@ -28,7 +28,14 @@
 				return this.$store.state.admin.selected
 			}
 		},
-		methods: {}
+		mounted () {
+			this.$store.commit('setMenuItem', this.$route.path.split('/')[2])
+		},
+		watch: {
+			$route (to, from) {
+				this.$store.commit('setMenuItem', to.path.split('/')[2])
+			}
+		}
 	}
 </script>