在微信浏览器中 location.reload() 不刷新解决方案(直接调用方法)

时间:2018-09-26 01:11:12   收藏:0   阅读:560

1、问题

  在微信浏览器中,需要时刷新当前页面。

  正常情况下我们直接使用 location.reload 方法来刷新。

 

2、解决方法

function realod(){
  var {search,href} = window.location;
  href = href.replace(/&?t_reload=(\d+)/g,‘‘)
  window.location.href = href+(search?‘&‘:‘?‘)+"t_reload="+new Date().getTime()
}

  

  直接调用该方法,兼容参数等形式。

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!