reactjs - 如何使用 React 和 iframe 在点击时获取 className?
问题描述
我想获取我在 iframe 中单击的任何内容的类名。
const getClassName = (e) => {
console.log(...)
}
<iframe src="somewikipediapage"/>
解决方案
在这篇文章之后,您可以使用此功能:
getNameOfChildrenClass() {
const singleChild = React.children.only(this.props.children),
childClass = child.type
return childClass.name
}
推荐阅读
- c# - 不要发布 sqlproj
- scala - 如何使用 Stream 正确调用方法?
- ssl - Coldfusion CFHTTP SSL 无客户端证书
- html - 为什么我的段落总是溢出div
- arrays - 如何将元素数组转换为 Scala 中可变元素方法的单个元素?
- css - iPhone X“下巴”导致 Cordova 应用程序无法利用空间
- c - 如何保持结构定义与其构造/销毁代码之间的相关性?
- json - 如何在 SQL Server 中正确解压缩 JSON 数组
- java - 我可以使用 nanoTime 代替 randomUUID 吗?
- android - Firestore 检查集合中是否存在文档