Преглед на файлове

Select menu item on route change and load

sbkwgh преди 8 години
родител
ревизия
03ff12e0f7
променени са 1 файла, в които са добавени 8 реда и са изтрити 1 реда
  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>