fix(Activities): 修复 WebView 缓存导致的页面不更新问题
问题描述:
- 用户报告活动页面 WebView 内容总是显示旧版本
- 即使后端 H5 页面已更新,小程序仍显示缓存内容
解决方案:
1. 添加 key 属性强制重新渲染
- 给 web-view 组件添加 :key="webUrl"
- URL 变化时强制销毁并重新创建 WebView
2. 添加时间戳参数破坏缓存
- 在 URL 末尾添加 &_t=${timestamp} 参数
- 确保每次请求的 URL 都不同,避免缓存命中
- 即使没有位置参数也添加时间戳
3. 增强调试日志
- 添加表情符号标记(✅ ❌ 🔗 📋)
- 输出完整 URL 和长度信息
- 便于排查缓存问题
测试建议:
- 清除小程序缓存后重新编译
- 查看控制台日志确认 URL 包含时间戳参数
- 验证每次进入页面 _t 值都不同
影响文件:
- src/pages/Activities/index.vue
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Showing
1 changed file
with
18 additions
and
7 deletions
-
Please register or login to post a comment