<div v-if="activeTab === 'staticData'" style="width:100%">
    <iframe height="100%" width="100%" :src="iframeSrc" id="staticData"></iframe>
</div>
setFrame() {
      this.projectId = localStorage.getItem('projectId');
      this.iframeSrc = `${process.env.BASE_URL}:8889/#/details? 
      perjectId=${this.projectId}&secret=${this.secret}&FmId=${this.$route.query.RoomID}&type=0&code=${this.$route.query.zone}`
}在vue项目中动态设置iframe的地址,iframe里面嵌套的是跨域内容,当地址变化后,iframe里的内容没有随着变。
使用:document.getElementById("staticData").contentWindow.location.reload(true);这个方法刷新iframe报错如下:
[b][b]Blocked a frame with origin "http://localhost:28080" from accessing a cross-origin frame.求问大神们有什么解决方法?

解决方案 »

  1.   

    这就是跨域请求问题。jsonp解决或在vue的配置文件里,配置本地代理proxyTable: {
          // 用‘/api’开头,代理所有请求到目标服务器
          '/api': {
            target: 'http://xxx.com', // 接口域名
            changeOrigin: true, // 是否启用跨域
            pathRewrite: { //
              '^/api': ''
            }
          }
    }