Reactjs window.print()无法在IE 11中使用react.js和react pdf库
window.print()在IE中似乎不起作用。我正在使用react.js和react pdf库 下面是我的示例代码:Reactjs window.print()无法在IE 11中使用react.js和react pdf库,reactjs,Reactjs,window.print()在IE中似乎不起作用。我正在使用react.js和react pdf库 下面是我的示例代码: import { Document, Page } from "react-pdf/build/entry.noworker"; class PrintFile extends React.Component { constructor(props) { super(props); } componentDidUpdate() { window
import { Document, Page } from "react-pdf/build/entry.noworker";
class PrintFile extends React.Component {
constructor(props) {
super(props);
}
componentDidUpdate() {
window.print();
}
render() {
const {
pdfFile,
} = this.props;
return (
<DocumentTitle title={pdfFile.name}>
<div id="printable">
<Document
file={pdfFile}
>
...
</Document>
</div>
</DocumentTitle>
);
}
}
PrintFile.propTypes = {
pdfFile: PropTypes.object,
};
export default PrintFile;
从“react pdf/build/entry.noworker”导入{Document,Page};
类PrintFile扩展了React.Component{
建造师(道具){
超级(道具);
}
componentDidUpdate(){
window.print();
}
render(){
常数{
Pdfile,
}=这是道具;
返回(
...
);
}
}
PrintFile.propTypes={
pdfFile:PropTypes.object,
};
导出默认打印文件;
我已经删除了逻辑,只是把基本的东西放在这里
是否调用打印组件更新?请不要使用覆盖window.print()等本机函数的libs@Sulthan替代方法是什么?