<div v-if="activeTab === 'staticData'" style="width:100%">
<iframe height="100%" width="100%" :src="https://bbs.csdn.net/topics/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.
求問大神們有什么解決方法?
uj5u.com熱心網友回復:
這就是跨域請求問題。jsonp解決或在vue的組態檔里,配置本地代理
proxyTable: {
// 用‘/api’開頭,代理所有請求到目標服務器
'/api': {
target: 'http://xxx.com', // 介面域名
changeOrigin: true, // 是否啟用跨域
pathRewrite: { //
'^/api': ''
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/131414.html
標籤:JavaScript
上一篇:求一H5移動端時間選擇器插件
下一篇:return
