Skip to content

Commit e23bafc

Browse files
修复动态路由和带参路由打开多个标签,标签滚动总是定位到最后一个同name标签的bug
1 parent c2d3969 commit e23bafc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/components/main/components/tags-nav/tags-nav.vue

+5-4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
ref="tagsPageOpened"
3434
:key="`tag-nav-${index}`"
3535
:name="item.name"
36+
:data-route-item="item"
3637
@on-close="handleClose(item)"
3738
@click.native="handleClick(item)"
3839
:closable="item.name !== $config.homeName"
@@ -159,11 +160,11 @@ export default {
159160
this.tagBodyLeft = -(tag.offsetLeft - (outerWidth - this.outerPadding - tag.offsetWidth))
160161
}
161162
},
162-
getTagElementByName (name) {
163+
getTagElementByName (route) {
163164
this.$nextTick(() => {
164165
this.refsTag = this.$refs.tagsPageOpened
165166
this.refsTag.forEach((item, index) => {
166-
if (name === item.name) {
167+
if (routeEqual(route, item.$attrs['data-route-item'])) {
167168
let tag = this.refsTag[index].$el
168169
this.moveToView(tag)
169170
}
@@ -185,7 +186,7 @@ export default {
185186
},
186187
watch: {
187188
'$route' (to) {
188-
this.getTagElementByName(to.name)
189+
this.getTagElementByName(to)
189190
},
190191
visible (value) {
191192
if (value) {
@@ -197,7 +198,7 @@ export default {
197198
},
198199
mounted () {
199200
setTimeout(() => {
200-
this.getTagElementByName(this.$route.name)
201+
this.getTagElementByName(this.$route)
201202
}, 200)
202203
}
203204
}

0 commit comments

Comments
 (0)