我试图用图像或文本代替Iframe时,它的URL拒绝连接,但我无法处理此错误,我不想解决x帧选项错误,我想处理它,以显示图像或消息时,Iframe无法连接exm1= =比;
<iframe key={random} src="https://www.youtube.com/embed/b4i7j6U7Ul8" width="100%" height="100%" sandbox="allow-scripts allow-same-origin allow-presentation" loading='lazy'/>
exm2= =比;This not work
<iframe key={random} src="https://www.google.com" width="100%" height="100%" sandbox="allow-scripts allow-same-origin allow-presentation" loading='lazy'/>
当Url拒绝与图像或文本连接时,我想替换Iframe标签
- const youtbe = "https://www.youtube.com/embed/b4i7j6U7Ul8">
- const image = "https://www.google.com/imgae">
<iframe key={random} src={error ? image : youtube} width="100%"
height="100%" sandbox="allow-scripts allow-same-origin
allow-presentation" loading='lazy'/>
src ={错误?图片来源:youtube}
在SRC:如果一个错误的图像将出现,如果没有YouTube将出现