vue iframe页面刷新停留在当前页面

在跳转iframe的时候 把 iframe 存储下来
刷新后判断是否存在保存的iframe
如果有 就赋值

 sliderClick(i, item) {
      this.sIndex = item.id;
      this.toggleSlider = true;
      this.iframeId = item.id;
      this.iframeUrl = item.linkUrl;
      localStorage.setItem("iframeUrl", item.linkUrl);
      localStorage.setItem("iframeId", item.id);
    },
 
mounted() {
if (localStorage.getItem("iframeUrl") && localStorage.getItem("iframeId")) { this.iframeUrl = localStorage.getItem("iframeUrl"); this.iframeId = localStorage.getItem("iframeId"); this.sIndex = localStorage.getItem("iframeId"); } }, created() { this.rout(); this.$root.eventHub.$off("iframesDate"); this.$root.eventHub.$on("iframesDate", (res) => { this.iframeUrl = res.linkUrl; this.sIndex = res.id; localStorage.setItem("iframeUrl", res.linkUrl); localStorage.setItem("iframeId", res.id); }); },

 

posted @ 2022-04-19 16:22  abcByme  阅读(775)  评论(0编辑  收藏  举报