From 8affc55a58037b9fbe7acf4f9707e80a220f5055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cchengxuan=E2=80=9D?= Date: Wed, 13 Feb 2019 17:39:30 +0800 Subject: [PATCH] keep-alive detail --- src/store/modules/tagsView.js | 29 +++++++++++++++++++++++++++++ src/views/example/detail.vue | 15 +++++++++++++++ src/views/example/list.vue | 22 ++++++++++++++++++++-- 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 src/views/example/detail.vue diff --git a/src/store/modules/tagsView.js b/src/store/modules/tagsView.js index cbf9eeb7..25ff9d11 100644 --- a/src/store/modules/tagsView.js +++ b/src/store/modules/tagsView.js @@ -1,3 +1,6 @@ +import Vue from 'vue' +import router from '@/router/index' +import Layout from '@/views/layout/Layout' const tagsView = { state: { visitedViews: [], @@ -155,6 +158,32 @@ const tagsView = { updateVisitedView({ commit }, view) { commit('UPDATE_VISITED_VIEW', view) + }, + addPageDetail({ commit, state }, params) { + return new Promise((resolve, reject) => { + const Detail = params.component + const Component = Vue.component(params.name, { + components: { Detail }, + render() { + return + } + }) + router.addRoutes([ + { + path: '', + component: Layout, + children: [ + { + path: params.path, + name: params.name, + component: Component, + meta: params.meta + } + ] + } + ]) + resolve() + }) } } } diff --git a/src/views/example/detail.vue b/src/views/example/detail.vue new file mode 100644 index 00000000..58d62f7c --- /dev/null +++ b/src/views/example/detail.vue @@ -0,0 +1,15 @@ + + + diff --git a/src/views/example/list.vue b/src/views/example/list.vue index 85ae4e43..c80dd47a 100644 --- a/src/views/example/list.vue +++ b/src/views/example/list.vue @@ -41,11 +41,12 @@ - + @@ -56,12 +57,14 @@