Open xiaoshi657 opened 5 years ago
不实现记忆好,你需要刷新的时候很难受。
src\router\index.js
/**
* Note: sub-menu only appear when route children.length >= 1
* Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
*
* hidden: true if set true, item will not show in the sidebar(default is false)
* alwaysShow: true if set true, will always show the root menu
* if not set alwaysShow, when item has more than one children route,
* it will becomes nested mode, otherwise not show the root menu
* redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
* name:'router-name' the name is used by <keep-alive> (must set!!!)
* meta : {
roles: ['admin','editor'] control the page roles (you can set multiple roles)
title: 'title' the name show in sidebar and breadcrumb (recommend set)
icon: 'svg-name' the icon show in the sidebar
noCache: true if set true, the page will no be cached(default is false)
affix: true if set true, the tag will affix in the tags-view
breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
}
*/
noCache 字段就是为了设置缓存用的默认状态下是有缓存的,当设置为 true 时候则没有缓存
刷新页面之后只有页面刷新之前所在的tagsview
和固定的tagsview
了的问题,属不属于这个症状啊?
@xiaoshi657 遇到了同样的问题,我自己的疏忽,以为是动态路由不会缓存,实际情况是,路由中的name字段必须有,组件中的name字段也必须有,且这两个字段要严格相等。
// router.js
{
path: '/icon',
component: Layout,
children: [{
path: 'index',
component: ()=>import('svg-icons/index'),
name: 'icons', // name字段 需要与组件中的name字段严格相等
meta: { title: 'icons', icon: 'icon' }
}]
}
// svg-icons/index.vue
<script>
export default {
name: 'icons',
data() {
return {}
}
}
</script>
路由配置中的name字段必须与组件中name字段严格相等,否则缓存会失效
所以组件文件必须有name字段 且此组件如果在路由表中,则必须与路由表中的name字段严格相等
Feature request(新功能建议)
现在的Tags-View可以实现快捷切换,但是切换后,之前的操作都没有了,等于重新进了一次。 希望可以实现记忆功能