# Solutions
Problems that we came across and solutions to them. If you have any better ideas, please feel free to propose a PR or issue.
A route can create different caches with different
route.params
orroute.query
:set a
key
prop to<router-view>
.Caches control with
<keep-alive>
:Get instance of
<keep-alive>
:this._vnode.children[0].child._vnode.componentInstance
Match and remove cache.
Match:
$alive.cache[i].data.key === key
Destroy:
$alive.cache[key].componentInstance.$destroy()
Remove
key
from$alive.keys
.
Refresh page component.
Remove cache of page.
Hide
<router-view>
byv-if
and show it after transition ends ornextTick
.
Get the routing depth where the current component is:
Recursively find the corresponding value of the nearest parent component with
$vnode.data.routerViewDepth
.Nested Routes share same tabs:
Get
path
of current matched route from$route.matched
.Visit page a from a keep-alive nested route, and go to a page of another route, then visit page b from the same nested route. The displayed page is still a:
Run
$forceUpdate
to force update the component on the pageactivated
.Side effect: Subroutine page a will still trigger the
activated
hookIframe tab gets reloaded on switching:
Extract
<iframe>
to outer layer of<router-view>
, and show/hide it viav-show
.Create a separate iframe route component, and manage
<iframe>
dom element in lifecycle hook methods, i.e., add, show, hide and remove.
Js bundle size gets too big:
When building as lib, set
useBuiltIns
tofalse
inbabel.config.js
, which means not including Polyfill in final bundle.
← Leave Confirm FAQ →