js、css后缀加V=随机数防止缓存

2025年03月05日 建站教程

为了防止js、css修改后出现缓存,我们一般会把当前年月日时分秒手动加上去,那么可以每次打开自动改变随机数吗?下面web建站小编给大家介绍一下!

方法一、Math.random()随机数

<script src="/static/static/config.js?v=<%=Math.random()%>"></script>

方法二、当前时间毫秒

<script src="/static/static/config.js?v=<%=new Date().getTime()%>"></script>

ps:支持vue项目,不支持纯html页面。

本文链接:http://so.lmcjl.com/news/24312/

展开阅读全文
相关内容