Skip to content

Commit

Permalink
Merge pull request #1061 from iview/2.0
Browse files Browse the repository at this point in the history
修复动态路由和带参路由打开多个标签,标签滚动总是定位到最后一个同name标签的bug
  • Loading branch information
Lison committed Nov 1, 2018
2 parents c2d3969 + e23bafc commit 614c0bf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/main/components/tags-nav/tags-nav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
ref="tagsPageOpened"
:key="`tag-nav-${index}`"
:name="item.name"
:data-route-item="item"
@on-close="handleClose(item)"
@click.native="handleClick(item)"
:closable="item.name !== $config.homeName"
Expand Down Expand Up @@ -159,11 +160,11 @@ export default {
this.tagBodyLeft = -(tag.offsetLeft - (outerWidth - this.outerPadding - tag.offsetWidth))
}
},
getTagElementByName (name) {
getTagElementByName (route) {
this.$nextTick(() => {
this.refsTag = this.$refs.tagsPageOpened
this.refsTag.forEach((item, index) => {
if (name === item.name) {
if (routeEqual(route, item.$attrs['data-route-item'])) {
let tag = this.refsTag[index].$el
this.moveToView(tag)
}
Expand All @@ -185,7 +186,7 @@ export default {
},
watch: {
'$route' (to) {
this.getTagElementByName(to.name)
this.getTagElementByName(to)
},
visible (value) {
if (value) {
Expand All @@ -197,7 +198,7 @@ export default {
},
mounted () {
setTimeout(() => {
this.getTagElementByName(this.$route.name)
this.getTagElementByName(this.$route)
}, 200)
}
}
Expand Down

0 comments on commit 614c0bf

Please sign in to comment.