Browse Source

fix: 替换url

zhenyulei 5 years ago
parent
commit
4ebfd4666d
2 changed files with 12 additions and 1 deletions
  1. 1 0
      src/packages/tabbar/doc.md
  2. 11 1
      src/packages/tabbar/tabbar.vue

+ 1 - 0
src/packages/tabbar/doc.md

@@ -76,6 +76,7 @@ export default {
 |----- | ----- | ----- | ----- 
 |----- | ----- | ----- | ----- 
 | tabbar-list | 渲染数据 | Array | []
 | tabbar-list | 渲染数据 | Array | []
 | bottom | 是否固定在页面底部 |Boolean|false|
 | bottom | 是否固定在页面底部 |Boolean|false|
+| replace | replace为true的时候,跳转url以替换的形式进行 |Boolean|false|
 
 
 ### tabbar-list
 ### tabbar-list
 
 

+ 11 - 1
src/packages/tabbar/tabbar.vue

@@ -6,7 +6,6 @@
       :class="[{ 'curr': index == currIndex }]"
       :class="[{ 'curr': index == currIndex }]"
       :key="value.tabTitle"
       :key="value.tabTitle"
       v-on:click="switchTabs(value, index)"
       v-on:click="switchTabs(value, index)"
-      :href="value.href"
     >
     >
     <nut-badge 
     <nut-badge 
         :isDot="value.isDot"
         :isDot="value.isDot"
@@ -43,6 +42,10 @@ export default {
     bottom: {
     bottom: {
       type: Boolean,
       type: Boolean,
       default: false
       default: false
+    },
+    replace:{
+      type: Boolean,
+      default: false
     }
     }
   },
   },
   data() {
   data() {
@@ -73,6 +76,13 @@ export default {
     },
     },
     switchTabs: function(value, index) {
     switchTabs: function(value, index) {
       this.currIndex = index;
       this.currIndex = index;
+      if(this.replace){ //替换url
+        window.location.replace(value.href);
+      }else{
+        if(value.href){
+          window.location.href = value.href;
+        }
+      }
       this.$emit('tab-switch', value, index);
       this.$emit('tab-switch', value, index);
     }
     }
   }
   }