From 41a5615ee5169a397f24948141d7ca0a0b4b82fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Thu, 18 Oct 2018 17:15:57 +0800 Subject: [PATCH] fix[TagsView]: fixed update tags title demo bug (#1223) --- src/views/example/components/ArticleDetail.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/views/example/components/ArticleDetail.vue b/src/views/example/components/ArticleDetail.vue index 4e3dca2c..6ac6feae 100644 --- a/src/views/example/components/ArticleDetail.vue +++ b/src/views/example/components/ArticleDetail.vue @@ -143,7 +143,8 @@ export default { title: [{ validator: validateRequire }], content: [{ validator: validateRequire }], source_uri: [{ validator: validateSourceUri, trigger: 'blur' }] - } + }, + tempRoute: {} } }, computed: { @@ -161,6 +162,11 @@ export default { } else { this.postForm = Object.assign({}, defaultForm) } + + // Why need to make a copy of this.$route here? + // 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 + // https://github.com/PanJiaChen/vue-element-admin/issues/1221 + this.tempRoute = Object.assign({}, this.$route) }, methods: { fetchData(id) { @@ -178,7 +184,7 @@ export default { }, setTagsViewTitle() { const title = this.lang === 'zh' ? '编辑文章' : 'Edit Article' - const route = Object.assign({}, this.$route, { title: `${title}-${this.postForm.id}` }) + const route = Object.assign({}, this.tempRoute, { title: `${title}-${this.postForm.id}` }) this.$store.dispatch('updateVisitedView', route) }, submitForm() {