用ref获取iframe节点时出现的问题

当我用this.$refs获取到iframe后,我该如何控制它让网页刷新

如果用Vue.js,可以这样刷新iframe:

this.$refs.iframeRef.contentWindow.location.reload();

如果用jQuery,可以这样刷新iframe:

$("#iframeId").attr("src", $("#iframeId").attr("src"));

如果需要在JavaScript中访问iframe中的内容,则可以使用contentWindow或contentDocument属性,例如:

const iframe = this.$refs.iframeRef;
const iframeWindow = iframe.contentWindow;
const iframeDocument = iframe.contentDocument;

但请注意,因为跨域限制,可能无法访问iframe中的内容。

1楼说的对,补充一下,如果跨域可以用
this.$refs.iframeRef.contentWindow.location.replace("http://xxxx%22/)
来固定替换就没事了

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^