From c9da05eb8ff3b0c0ecc2b2d2d372c35aa7477812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=8F=8F?= Date: Tue, 25 Aug 2020 10:15:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=A0=8F=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=8D=95=E9=A1=B5=E9=9D=A2=E5=88=B7=E6=96=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.移除带参路由来回切换data 2.只刷新当前router,不影响其他已缓存的router --- .../header-aside/components/tabs/index.vue | 11 +++++++ src/layout/header-aside/layout.vue | 2 +- .../demo/playground/page-cache/params.vue | 30 ------------------- src/views/system/function/refresh/index.js | 3 +- 4 files changed, 14 insertions(+), 32 deletions(-) diff --git a/src/layout/header-aside/components/tabs/index.vue b/src/layout/header-aside/components/tabs/index.vue index d83e4f43..4ca15fe3 100644 --- a/src/layout/header-aside/components/tabs/index.vue +++ b/src/layout/header-aside/components/tabs/index.vue @@ -27,6 +27,9 @@
+ + + - +
diff --git a/src/views/demo/playground/page-cache/params.vue b/src/views/demo/playground/page-cache/params.vue index c1a50429..6d5a388c 100644 --- a/src/views/demo/playground/page-cache/params.vue +++ b/src/views/demo/playground/page-cache/params.vue @@ -39,38 +39,8 @@ export default { }, data () { return { - datas: [], data: { value: '' } } - }, - methods: { - switchData (id) { - let data = this.datas[id] - if (!data) { - data = { value: '' } - this.datas[id] = data - } - this.data = data - } - }, - // 第一次进入或从其他组件对应路由进入时触发 - beforeRouteEnter (to, from, next) { - const id = to.params.id - if (id) { - next(instance => instance.switchData(id)) - } else { - next(new Error('未指定ID')) - } - }, - // 在同一组件对应的多个路由间切换时触发 - beforeRouteUpdate (to, from, next) { - const id = to.params.id - if (id) { - this.switchData(id) - next() - } else { - next(new Error('未指定ID')) - } } } diff --git a/src/views/system/function/refresh/index.js b/src/views/system/function/refresh/index.js index e8b35034..03ef5ad8 100644 --- a/src/views/system/function/refresh/index.js +++ b/src/views/system/function/refresh/index.js @@ -1,6 +1,7 @@ export default { beforeRouteEnter (to, from, next) { - next(instance => instance.$router.replace(from.fullPath)) + from.meta[from.path] = Date.now() + next(instance => instance.$router.replace({ path: from.fullPath, meta: from.meta })) }, render: h => h() }