我试了几次,用不同的方法。我想检查 if 语句的第一个值是否是 iframe。谁能向我解释我在这里做错了什么?我真的很困惑。我需要检查该值是否为 iframe,因此如果该值不是,我可以使用一些 css 隐藏 div 我尝试了几种不同的变体,但我没有找到正确的语法来检查我是否正确。目前该值始终是 iframe,但下一步将是集成或提供 1x1 像素。这就是为什么我必须检查它
const containerToProof = useRef()
useEffect(()=>{
// console.log('saysomething',containerToProof.current.firstElementChild.innerHTML)
var isiframe = containerToProof.current.firstElementChild.innerHTML;
console.log('isiframe', isiframe);
if(isiframe.tagName=== iframe){
console.log('allo')
setAdSpotvisible(true)
}else{
setAdSpotvisible(false)
}
},[<iframe/>]);
/*
if(containerToProof.current=='iframe'){
console.log('allo')
}*/
return (
<div>
<div ref={containerToProof} ></div>
);`````