From d005ff52826f57760bb146c3d6a457445fe32961 Mon Sep 17 00:00:00 2001 From: ewall <1054064180@qq.com> Date: Fri, 3 Apr 2020 15:24:36 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9Akeep-alive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 2 +- src/components/GoodsItem/index.vue | 5 ++++- src/components/ProductItem/index.vue | 5 ++++- src/components/SessionItem/index.vue | 5 ++++- src/router/index.js | 13 ++++++++++--- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/App.vue b/src/App.vue index 2dfe547..130fd32 100644 --- a/src/App.vue +++ b/src/App.vue @@ -18,7 +18,7 @@ export default { }, computed: { key() { - return this.$route.path + return this.$route.fullPath } } } diff --git a/src/components/GoodsItem/index.vue b/src/components/GoodsItem/index.vue index bbb15ac..910a981 100644 --- a/src/components/GoodsItem/index.vue +++ b/src/components/GoodsItem/index.vue @@ -21,7 +21,10 @@ export default { methods: { onNavigate() { this.$router.push({ - path: '/detail' + path: '/detail', + query: { + t: +new Date() + } }) } } diff --git a/src/components/ProductItem/index.vue b/src/components/ProductItem/index.vue index a4641c5..c76e0fe 100644 --- a/src/components/ProductItem/index.vue +++ b/src/components/ProductItem/index.vue @@ -30,7 +30,10 @@ export default { methods: { onClick() { this.$router.push({ - path: '/detail' + path: '/detail', + query: { + t: +new Date() + } }) } } diff --git a/src/components/SessionItem/index.vue b/src/components/SessionItem/index.vue index 55b8880..2956180 100644 --- a/src/components/SessionItem/index.vue +++ b/src/components/SessionItem/index.vue @@ -44,7 +44,10 @@ export default { methods: { onClick() { this.$router.push({ - path: '/product' + path: '/product', + query: { + t: +new Date() + } }) } } diff --git a/src/router/index.js b/src/router/index.js index 9b6c2c4..3fe3643 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -12,7 +12,8 @@ const routes = [ // webpackPreload:https://www.jianshu.com/p/bbdcfeee7fbc component: () => import(/* webpackPreload: true */ '@/views/home'), meta: { - showTab: true + showTab: true, + keepAlive: true } }, // 登录 @@ -49,13 +50,19 @@ const routes = [ { path: '/product', name: 'Product', - component: () => import('@/views/product') + component: () => import('@/views/product'), + meta: { + keepAlive: true + } }, // 商品详情 { path: '/detail', name: 'Detail', - component: () => import('@/views/detail') + component: () => import('@/views/detail'), + meta: { + keepAlive: true + } }, // 地址管理 {