Browse Source

keepalive

wolyshaw 4 years ago
parent
commit
bfa61272e5

+ 3 - 3
src/components/save-form/index.vue

@@ -13,7 +13,7 @@ export default {
   name: 'save-form',
   props: ['model', 'rules', 'formProps'],
   mounted() {
-    const searchs = getSearchs(this.$route.fullpath)
+    const searchs = getSearchs(this.$route.fullPath)
     for (const key in searchs) {
       if (searchs.hasOwnProperty(key)) {
         const item = searchs[key];
@@ -21,7 +21,7 @@ export default {
       }
     }
     console.log(this.$refs.form)
-    console.log(getSearchs(this.$route.fullpath))
+    console.log(getSearchs(this.$route.fullPath))
   },
   methods: {
     validate(FC) {
@@ -29,7 +29,7 @@ export default {
         FC(valid)
         if (valid) {
           console.log(this.$route, this.model)
-          saveToStorage(this.$route.fullpath, this.model)
+          saveToStorage(this.$route.fullPath, this.model)
         }
       })
     },

+ 6 - 1
src/layout/components/AppMain.vue

@@ -3,20 +3,25 @@
     <!--   -->
     <transition name="fade-transform"
                 mode="out-in">
-      <keep-alive>
+      <keep-alive v-if="needKeep">
         <router-view :key="key" />
       </keep-alive>
+      <router-view v-else :key="key" />
     </transition>
   </section>
 </template>
 
 <script>
+import notKeepAliveList from '@/router/notKeepAliveList'
 export default {
   name: 'AppMain',
   computed: {
     key () {
       return this.$route.path
     },
+    needKeep() {
+      return !notKeepAliveList.includes(this.$route.fullPath)
+    },
     cachedViews () {
       return this.$store.state.tagsView.cachedViews
     },

+ 3 - 0
src/router/notKeepAliveList.js

@@ -0,0 +1,3 @@
+export default [
+  '/setSilder/save-form'
+]

+ 8 - 0
src/views/save-form-test/modals/test.vue

@@ -0,0 +1,8 @@
+<template>
+  <div>弹窗状态测试</div>
+</template>
+<script>
+export default {
+
+}
+</script>