Home > front end >  Vue and iframe
Vue and iframe

Time:10-22




SetFrame () {
This. ProjectId=localStorage. The getItem (" projectId ");
Enclosing iframeSrc=https://bbs.csdn.net/topics/` ${process. The env. BASE_URL} : # 8889//details?
PerjectId=${this. ProjectId} & amp; Secret=${this. Secret} & amp; FmId=${this. $route. Query. RoomID} & amp; Type=0 & amp; Code=${this. $route. Query. Zone} `
}

Dynamic in vue program set the address of the iframe, nested inside the iframe is cross-domain content, after the address changes, the content in the iframe as change,
Use: the document. The getElementById (" staticData "). The contentWindow. Location. Reload (true); This method to refresh the iframe error is as follows:
[b] [b] Blocked a frame with origin "http://localhost:28080" from accessing a cross - origin frame.

Inquire of the great god what's the solution?

CodePudding user response:

This is the problem of cross-domain request, the json solution or in the configuration files of the vue, configure the local agent
 
ProxyTable: {
//begins with '/API, the acting all requests to the target server
'/API: {
Target: 'http://xxx.com',//interface domain name
ChangeOrigin: true,//if enabled cross-domain
PathRewrite: {//
'^/API' : '
}
}
}
  • Related