首页 > 解决方案 > 如何在打字稿中使用 react-to-print

问题描述

          <span className={styles.headerText3}>
          <ReactToPrint
            trigger={() =><Button
              className={styles.buttonColor}
              
            >
              <AiOutlinePrinter />
            </Button>}
            content={() => this.componentRef}
            />
            <Table1 ref={el => (this.componentRef = el)} />

我已经按照 react-to-print 中提到的那样尝试了这个,但是它在 this.componentRef 上抛出了错误。我正在使用打字稿,也许这就是问题所在。如何使反应打印在 TS 上工作。

标签: reactjstypescriptreact-to-print

解决方案


推荐阅读