想iframe嵌入页面注入css
const loadComponyIframe = ()=>{ let componyRelIframe = document.getElementById("componyIframe"); let iframeDoc = componyRelIframe.contentWindow.document; let iframeHead = iframeDoc.getElementsByTagName('head'); let linkTag = document.createElement('link'); linkTag.id = 'newstyle'; linkTag.href = `${APP_URL}/static/2209/iframe.css`; linkTag.setAttribute('rel', 'stylesheet'); linkTag.setAttribute('type', 'text/css'); iframeHead[0].appendChild(linkTag) } <iframe onLoad={loadComponyIframe} id="componyIframe" className='model_iframe' width="100%" min-height="400px" border="none" src={orgUrl}></iframe>