Browse Source

路由修改完成OYEA

xjc 4 years ago
parent
commit
262ee89282
4 changed files with 18 additions and 30 deletions
  1. 2 2
      src/router.js
  2. 14 26
      src/views/Home.vue
  3. 1 1
      src/views/Index.vue
  4. 1 1
      src/views/Login.vue

+ 2 - 2
src/router.js

@@ -10,14 +10,14 @@ export default new Router({
       show: 0,
     },
     {
-      path: '/',
+      path: '/index/index',
       name: '首页',
       icon: 'el-icon-s-home',
       component: () => import('./views/Home.vue'),
       show: 1,
       isLeaf: 1,
       children: [{
-        path: '/',
+        path: '/index/index',
         component: () => import('./views/Index.vue'),
         name: '首页'
       }, ]

+ 14 - 26
src/views/Home.vue

@@ -9,7 +9,7 @@
 				期刊微信公众号管理系统
 			</div>	
 			<div class="nav">
-				<router-link class="active" to="/">首页</router-link>
+				<router-link class="active" to="/index/index">首页</router-link>
 				<router-link to="">期刊管理</router-link>
 				<router-link to="">刊群导览</router-link>
 				<router-link to="">学术交流</router-link>
@@ -77,6 +77,18 @@
 import Router from 'vue-router'
 export default {
 	name: 'home',
+	watch:{
+		$route(to,from){
+			let mod = to.path.split("/")[1];
+			this.$router.options.routes.forEach((element,i) => {
+				if(element.path.indexOf(mod)==-1){
+					element.show = 0
+				}else{
+					element.show = 1
+				}
+			});
+		}
+	},
 	data() {
 		return {
 			checkedCompany:'',
@@ -115,34 +127,10 @@ export default {
 		},
 		getData(){
 		
-		},
-		toPath(e){
-			let mod = e.target.hash.split("/")[1];
-			this.$router.options.routes.forEach((element,i) => {
-				if(element.path.indexOf(mod)==-1){
-					this.$router.options.routes[i].show = 1
-					// element.show = 0
-				}else{
-					this.$router.options.routes[i].show = 0
-					// element.show = 1
-				}
-			});
 		}
 	},
 	created(){
-		let mod = this.$route.path.split("/")[1];
-		this.$router.options.routes.forEach((element,i) => {
-			console.log(element.path,333333333333)
-			console.log(element.path.indexOf(mod))
-			if(element.path.indexOf(mod)==-1){
-				// this.$router.options.routes[i].show = 0
-				element.show = 0
-			}else{
-				// this.$router.options.routes[i].show = 1
-				element.show = 1
-			}
-		});
-
+		
 	}
 };
 </script>

+ 1 - 1
src/views/Index.vue

@@ -1,3 +1,3 @@
 <template>
-    <section></section>
+    <section>111111</section>
 </template>

+ 1 - 1
src/views/Login.vue

@@ -138,7 +138,7 @@ export default {
             this.$api.login(parms).then((res)=>{
                 let data=res.data
                   if(res.data.code == 0){
-                      window.location.hash='/';
+                      window.location.hash='/index/index';
                   }else{
                       this.$message.error("账号或者密码有误");
                   }