Procházet zdrojové kódy

Select menu item on route change and load

sbkwgh před 8 roky
rodič
revize
03ff12e0f7
1 změnil soubory, kde provedl 8 přidání a 1 odebrání
  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>