瀏覽代碼

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>