如果前端不需要獲取接口的返回數(shù)據(jù),可以使用iframe來解決跨域問題
let iframe=document.createElement('iframe')
document.body.appendChild(iframe)
//接口地址
iframe.src='xxx' //跨域接口地址
iframe.id='#hookIframe'
iframe.style.display='none' //隱藏iframe
iframe.addEventListener('load',function(){
//調(diào)用完成后移除iframe
document.body.removeChild(iframe)
})