| | |
| | | :key="index" |
| | | :id="'tags-box-' + index" |
| | | @contextmenu.prevent="openMenu(item, $event)" |
| | | :class="isActive(item.url, item.index,index) ? 'active' : ''" |
| | | :class="isActive(item.url, item.index) ? 'active' : ''" |
| | | class="tagsview" |
| | | @click="tagsmenu(item, index)" |
| | | > |
| | |
| | | } |
| | | } else { |
| | | // 那么,如果上面的条件都不成立,没有length=0.也就是说你还有好几个标签,并且你删除的是最后一位标签,那么就往左边挪一位跳转路由 |
| | | this.$router.push({ path: this.tags[index - 1].url, query: { param: this.tags[index - 1].params } }) |
| | | this.$router.push({ |
| | | path: this.tags[index - 1].url, |
| | | query: { index: this.tags[index - 1].index, param: this.tags[index - 1].params } |
| | | }) |
| | | } |
| | | } else { |
| | | // 如果你点击不是最后一位标签,点的前面的,那就往右边跳转 |
| | | this.$router.push({ path: this.tags[index].url, query: { param: this.tags[index].params } }) |
| | | this.$router.push({ |
| | | path: this.tags[index].url, |
| | | query: { index: this.tags[index].index, param: this.tags[index].params } |
| | | }) |
| | | } |
| | | }, |
| | | // 点击跳转路由 |
| | | tagsmenu (item, index) { |
| | | console.log('tagsmenu') |
| | | // 判断:当前路由不等于当前选中项的url,也就代表你点击的不是现在选中的标签,是另一个标签就跳转过去,如果你点击的是现在已经选中的标签就不用跳转了,因为你已经在这个路由了还跳什么呢。 |
| | | if (this.$route.path !== item.url) { |
| | | // 用path的跳转方法把当前项的url当作地址跳转。 |
| | | this.$router.push({ path: item.url, query: { index: this.tags[index].index, param: this.tags[index].params, time: (Math.random().toString())} }) |
| | | // this.$router.push( item.url) |
| | | if (this.$route.path !== item.url || this.$route.query.index !== item.index) { |
| | | this.$router.push({ |
| | | path: item.url, |
| | | query: { |
| | | index: item.index, |
| | | param: item.params, |
| | | time: (Math.random().toString()) |
| | | } |
| | | }) |
| | | const tagsDiv = document.getElementById('tags-box') |
| | | if (index) { |
| | | if (tagsDiv && index) { |
| | | tagsDiv.scrollTo(index * 110, 0) |
| | | } |
| | | } |
| | | // this.computeTableHeight() |
| | | }, |
| | | computeTableHeight () { |
| | | this.$nextTick(() => { |
| | |
| | | return dv || 0 |
| | | }, |
| | | // 通过判断路由一致返回布尔值添加class,添加高亮效果 |
| | | isActive (route, params, index) { |
| | | const res = (route === this.$route.path && params == this.$route.query.index) |
| | | return res |
| | | isActive (route, index) { |
| | | return route === this.$route.path && index === this.$route.query.index |
| | | }, |
| | | scrollToStart () { |
| | | const tagsDiv = document.getElementById('tags-box') |