小工具知识网

当前位置: 首页 > 行业知识 > vue3 keep-alive include失效问题

行业知识

vue3 keep-alive include失效问题

2026-11-04 12:10:43 来源:互联网转载

在index.php/tags-602.html" >使用vue3 keep-alive时,发现并没有起作用, 代码如下:

                        import { useLayoutStore } from '../../../stores';import { storeToRefs } from 'pinia';const store = useLayoutStore();const { cachedViews } = storeToRefs(store);.app-main {  padding: 10px;  height: calc(100vh - 90px);  width: 100%;}

这里的include绑定的是路由名称的数组,看着没什么问题,就是不起作用。

原来vue3的setup无法组件命名,keep-alive include必须要组件命名

所以在需要添加缓存的组件中,添加:

export default { name: 'charts1' };

这里的charts1就是该组件名,对应路由的name也是charts1。

参考地址:https://blog.csdn.net/guang_sszbs/article/details/123236594

 

上一篇:王牌竞速服务器怎么选择?

下一篇:查找视频服务器地址怎么查?