Skip to content

Commit 41a5615

Browse files
authored
fix[TagsView]: fixed update tags title demo bug (#1223)
1 parent df23405 commit 41a5615

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/views/example/components/ArticleDetail.vue

+8-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ export default {
143143
title: [{ validator: validateRequire }],
144144
content: [{ validator: validateRequire }],
145145
source_uri: [{ validator: validateSourceUri, trigger: 'blur' }]
146-
}
146+
},
147+
tempRoute: {}
147148
}
148149
},
149150
computed: {
@@ -161,6 +162,11 @@ export default {
161162
} else {
162163
this.postForm = Object.assign({}, defaultForm)
163164
}
165+
166+
// Why need to make a copy of this.$route here?
167+
// Because if you enter this page and quickly switch tag, may be in the execution of the setTagsViewTitle function, this.$route is no longer pointing to the current page
168+
// https://github.com./PanJiaChen/vue-element-admin/issues/1221
169+
this.tempRoute = Object.assign({}, this.$route)
164170
},
165171
methods: {
166172
fetchData(id) {
@@ -178,7 +184,7 @@ export default {
178184
},
179185
setTagsViewTitle() {
180186
const title = this.lang === 'zh' ? '编辑文章' : 'Edit Article'
181-
const route = Object.assign({}, this.$route, { title: `${title}-${this.postForm.id}` })
187+
const route = Object.assign({}, this.tempRoute, { title: `${title}-${this.postForm.id}` })
182188
this.$store.dispatch('updateVisitedView', route)
183189
},
184190
submitForm() {

0 commit comments

Comments
 (0)