Browse Source

路由标签添加边界

gjy 2 years ago
parent
commit
a70b6c2bd9
1 changed files with 12 additions and 3 deletions
  1. 12 3
      src/components/syClick.vue

+ 12 - 3
src/components/syClick.vue

@@ -40,13 +40,22 @@
         methods: {
         methods: {
             navleft(){
             navleft(){
                 this.left+=100
                 this.left+=100
-                console.log(this.left)
-                this.$refs.navclickwrap.style.left = -this.left+'px'
+                if(this.left<this.$refs.navclickwrap.offsetWidth){
+                   this.$refs.navclickwrap.style.left = -this.left+'px' 
+                }else{
+                    this.left=this.$refs.navclickwrap.offsetWidth
+                    this.$refs.navclickwrap.style.left = -this.$refs.navclickwrap.offsetWidth+'px' 
+                }
             },
             },
             navright(){
             navright(){
                  this.left-=100
                  this.left-=100
                 console.log(this.left)
                 console.log(this.left)
-                this.$refs.navclickwrap.style.left = -this.left+'px'
+                if(-this.left<0){
+                   this.$refs.navclickwrap.style.left = -this.left+'px' 
+                }else{
+                    this.left=0
+                    this.$refs.navclickwrap.style.left = '0px' 
+                }
             },
             },
             // 删除标签页
             // 删除标签页
             removeTag(index) {
             removeTag(index) {