【JS】解决 iframe 中 src 更改页面未刷新问题

文章目录

  1. 背景:系统内嵌iframe,iframe 的 src 修改了,但是 iframe 内部页面未更新

  2. 原因:iframe 中 src 如果是 hash 路由带 # 的,当 src 改变是不会刷新的

  3. 解决方法:这时候在 # 号前追加一个随机数或者时间戳

// # 前面无其他参数
const url = `https://xxx域名xxx/?${
      
      new Date().getTime()}#/test/?id=666`;
// # 前面有其他参数
const url = `https://xxx域名xxx/?embed=true&${
      
      new Date().getTime()}#/test/?id=666`;

猜你喜欢

转载自blog.csdn.net/qq_45677671/article/details/132409669