panhui преди 4 години
родител
ревизия
15dda4384c
променени са 1 файла, в които са добавени 24 реда и са изтрити 2 реда
  1. 24 2
      src/main/nine-space/src/components/AppBar.vue

+ 24 - 2
src/main/nine-space/src/components/AppBar.vue

@@ -12,6 +12,9 @@
         :border="false"
         :border="false"
     >
     >
         <template #left>
         <template #left>
+            <div class="back">
+                <van-icon @click="back" size="24" name="arrow-left" color="#fff" />
+            </div>
             <van-popover
             <van-popover
                 v-model:show="showPopover"
                 v-model:show="showPopover"
                 placement="bottom-start"
                 placement="bottom-start"
@@ -37,8 +40,7 @@ export default {
                 { text: '首页', icon: require('../assets/menu1.png'), value: '/home' },
                 { text: '首页', icon: require('../assets/menu1.png'), value: '/home' },
                 { text: '发现', icon: require('../assets/menu2.png'), value: '/discover' },
                 { text: '发现', icon: require('../assets/menu2.png'), value: '/discover' },
                 { text: '柜子', icon: require('../assets/menu3.png'), value: '/store' },
                 { text: '柜子', icon: require('../assets/menu3.png'), value: '/store' },
-                { text: '我的', icon: require('../assets/menu4.png'), value: '/mine' },
-                { text: '上一页', icon: 'arrow-left', value: 'back' }
+                { text: '我的', icon: require('../assets/menu4.png'), value: '/mine' }
             ]
             ]
         };
         };
     },
     },
@@ -57,6 +59,7 @@ export default {
         } else {
         } else {
             this.show = true;
             this.show = true;
         }
         }
+        console.log(this.$route);
     },
     },
     methods: {
     methods: {
         onSelect(val) {
         onSelect(val) {
@@ -65,7 +68,26 @@ export default {
             } else {
             } else {
                 this.$router.push(val.value);
                 this.$router.push(val.value);
             }
             }
+        },
+        back() {
+            if (window.history.length <= 1) {
+                this.$router.push({ path: '/' });
+                return false;
+            } else {
+                this.$router.go(-1);
+            }
+            //上面都没执行就说明卡在当前页不是最后一条, histroy记录数量大于1,又没有回退记录,只能返回首页,
+            //如果上面都执行了 页面都跳走了,这个也就不用管了
+            setTimeout(() => {
+                this.$router.push({ path: '/' });
+            }, 500);
         }
         }
     }
     }
 };
 };
 </script>
 </script>
+
+<style lang="less">
+.back {
+    padding-right: 12px;
+}
+</style>