网上商城网站开发公司,前端开发岗位,跟知乎一样的网站,博爱网站建设我正在尝试构建一个组件,带孩子和渲染DOM中的子项,以及出于文档的目的,在pre中显示子DOM一种解决方案是将JSX作为单独的prop传递.这使得它重复,因为我已经能够通过this.props.children访问它.理想情况下,我只需要以某种方式将子prop转换为字符串,以便我可以在pre中…我正在尝试构建一个组件,带孩子和渲染DOM中的子项,以及出于文档的目的,在pre中显示子DOM一种解决方案是将JSX作为单独的prop传递.这使得它重复,因为我已经能够通过this.props.children访问它.理想情况下,我只需要以某种方式将子prop转换为字符串,以便我可以在pre中呈现它以显示“此代码生成此结果”.这就是我到目前为止所拥有的class DocumentationSection extends React.Component{render(){return {heading || }{this.props.children}//Change this to produce a JSX string from the elements{this.props.children};}}如何以’ Div className myDiv … / Div格式获取jsx字符串当我将DocumentationSection渲染为...谢谢.编辑我试过toString,它dint work,给了[object Object]