圆月山庄资源网 Design By www.vgjia.com
问题是这样的,我使用webpack的npm run dev运行的时候,keep-alive路由缓存是有效的,但是我npm run build,把文件放到实际的项目中去的时候,会有如下的问题:
路由如下:
var menus = [ { path: '/user', name: '用户', component: '/user', redirect: '/user/index1', icon: 'fa-bandcamp', meta: { keepAlive: false }, children: [ { path: 'index1', component: '/user/index1', name: '用户管理1', meta: {keepAlive: true}}, { path: 'index2', component: '/user/index2', name: '用户管理2', meta: {keepAlive: true}}, ] },{ path: '/system', name: 'system', component: '/system', redirect: '/system/index', icon: 'fa-superpowers', noDropdown: true, meta: { keepAlive: false }, children: [ { path: 'index', component: '/system/index', name: '系统管理', meta: {keepAlive: true}}, ] }, ]
我在 /user/index1 和/user/index2 之间做切换的时候路由缓存还是生效的,但是在user和system之间切换的时候就不生效了,解决方法如下,也解释不清楚什么原因,可能生产环境下需要在路由的文件上面做缓存把
在route目录下新建两个文件:
_import_development.js
module.exports = file => require('@/views/' + file + '.vue')
_import_production.js
module.exports = file => () => import('@/views/' + file + '.vue')
原先路由import的时候是这样的:
import Home from '@/views/home/homeView'
现在改成这样:
const _import = require('./_import_' + process.env.NODE_ENV); const Login = _import('index/loginView')
重新打包运行生效!
以上这篇vue解决使用webpack打包后keep-alive不生效的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com
暂无评论...
更新日志
2024年10月11日
2024年10月11日
- 伊能静.1989-悲伤的茱丽叶【飞鹰唱片】【WAV+CUE】
- 黑神话二郎神脸模再次COS自己:霸气侧漏 颜值超高!
- 《黑神话》萍萍演员再晒COS:国庆皮肤限时返场!
- 《暗黑4》资料片IGN 8分:新增内容令人相当满意!
- 《一人一首成名曲·怀旧篇 3CD》[WAV+CUE][1.5GB]
- 《张信哲 粤语精选集 从开始到现在 2CD》[WAV+CUE][780MB]
- 《中国歌典 1950-1999年代经典歌曲 10CD》[FLAC/分轨][3.5GB]
- 群星.2024-流水迢迢影视原声带【诗和远方】【FLAC分轨】
- 蓝心湄.1999-心湄看新湄【SONY】【WAV+CUE】
- FINE乐团.2022-宇宙神经【FLAC分轨】
- 万代南梦宫逼迫中国选手弃权《铁拳》比赛 国籍不符合资格
- 《黑神话》官方手办引热议:真的很好看真的买不起
- 《黑神话:悟空》取景地灵岩寺现巨型悟空!挥舞大棒超帅气
- 秦咏.1997-歌咏诗情·历年名曲典故【音乐谷】【WAV+CUE】
- 群星.1997-纯电影·电影歌曲剧照纪念篇【新艺宝】【WAV+CUE】