Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ant-design-pro-vue
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tianzhuanghu
ant-design-pro-vue
Commits
ea9404d2
Unverified
Commit
ea9404d2
authored
Mar 25, 2019
by
Sendya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: custom route-view keepAlive
parent
692f0f87
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
PageView.vue
src/layouts/PageView.vue
+10
-1
RouteView.vue
src/layouts/RouteView.vue
+8
-2
No files found.
src/layouts/PageView.vue
View file @
ea9404d2
...
@@ -41,7 +41,10 @@
...
@@ -41,7 +41,10 @@
<div
class=
"page-header-index-wide"
>
<div
class=
"page-header-index-wide"
>
<slot>
<slot>
<!-- keep-alive -->
<!-- keep-alive -->
<router-view
ref=
"content"
></router-view>
<keep-alive
v-if=
"multiTab"
>
<router-view
ref=
"content"
/>
</keep-alive>
<router-view
v-else
ref=
"content"
/>
</slot>
</slot>
</div>
</div>
</div>
</div>
...
@@ -49,6 +52,7 @@
...
@@ -49,6 +52,7 @@
</template>
</template>
<
script
>
<
script
>
import
{
mapState
}
from
'vuex'
import
PageHeader
from
'@/components/PageHeader'
import
PageHeader
from
'@/components/PageHeader'
export
default
{
export
default
{
...
@@ -80,6 +84,11 @@ export default {
...
@@ -80,6 +84,11 @@ export default {
tabs
:
{}
tabs
:
{}
}
}
},
},
computed
:
{
...
mapState
({
multiTab
:
state
=>
state
.
app
.
multiTab
})
},
mounted
()
{
mounted
()
{
this
.
getPageMeta
()
this
.
getPageMeta
()
},
},
...
...
src/layouts/RouteView.vue
View file @
ea9404d2
<
script
>
<
script
>
export
default
{
export
default
{
name
:
'RouteView'
,
name
:
'RouteView'
,
props
:
{
keepAlive
:
{
type
:
Boolean
,
default
:
true
}
},
data
()
{
data
()
{
return
{}
return
{}
},
},
...
@@ -17,10 +23,10 @@ export default {
...
@@ -17,10 +23,10 @@ export default {
// 这里增加了 multiTab 的判断,当开启了 multiTab 时
// 这里增加了 multiTab 的判断,当开启了 multiTab 时
// 应当全部组件皆缓存,否则会导致切换页面后页面还原成原始状态
// 应当全部组件皆缓存,否则会导致切换页面后页面还原成原始状态
// 若确实不需要,可改为 return meta.keepAlive ? inKeep : notKeep
// 若确实不需要,可改为 return meta.keepAlive ? inKeep : notKeep
if
(
meta
.
keepAlive
===
false
)
{
if
(
!
getters
.
multiTab
&&
meta
.
keepAlive
===
false
)
{
return
notKeep
return
notKeep
}
}
return
getters
.
multiTab
||
meta
.
keepAlive
?
inKeep
:
notKeep
return
this
.
keepAlive
||
getters
.
multiTab
||
meta
.
keepAlive
?
inKeep
:
notKeep
}
}
}
}
</
script
>
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment