写更换背景图片功能时,由于上传后图片同一命名,导致新的图片没有加载。

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/icebns/article/details/102575806
问题:
写更换背景图片功能时,由于上传后图片同一命名,导致新的图片没有加载。

解决方法:

1.meta部分:

<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">

2.JS部分:图片src+'?t='+(+new Date())

axios({
 url:showcenterip+"/savaWorkinterfaceInformation.json?tokena="+tokena,
 method:"post",
 data:formData, 
})
.then(function(response){
    console.log("程序执行");
    localStorage.setItem("backgroundPicUrl",response.data.backgroundPicUrl);
    $("#bgimg").attr("src","#");
    $("#bgimg").attr("src",showcenterip+response.data.backgroundPicUrl+'?t='+(+new Date())); 
})

猜你喜欢

转载自blog.csdn.net/icebns/article/details/102575806