如何在react js中打印多个组件?

时间:2018-05-28 11:10:50

标签: reactjs pdf printing

我的父组件有多个组件,如下面的

    class DashboardPage extends Component {
        render() {
            const { classes } = this.props;
            return (
                <div>
                  <ReactToPrint
                      className={classes.content}
                      trigger={() => <a href="#">Print this out!</a>}
                      content={() => this.componentRef} 
                  />
                  <Card>
                    <ProfileHeader {...this.state}/>
                    <ContentLeft {...this.state}/>
                    <ContentRight {...this.state}/>
                    <ContentLeft1 {...this.state}/>
                    <ContentRight1 {...this.state}/>
                    <ProjectTopic {...this.state}/>
                    <ProjectContent {...this.state}/>
                    <ProjectTopic1 {...this.state}/>
                    <ProjectContent1 {...this.state}/>
                    <ProjectTopic2 {...this.state}/>
                    <ProjectContent2 {...this.state}/>
                  </Card>
              </div>
            );
        }
    }

如果我想打印1个组件,我可以在代码下面使用

<ComponentToPrint ref={el => (this.componentRef = el)} />

如何在卡片标签内使用某些内容,以便我可以打印每个组件

  

请帮助我这个新手

0 个答案:

没有答案