javascript - React + Electron 如何打印 HTML?

标签 javascript reactjs electron

我正在使用 react 和 Electron 。当我按下按钮时,我需要在 React 应用程序中打印一些生成的 HTML:

<FlatButton label='Print' primary={true} onTouchTap={this.props.print} />

但问题是, Electron 中的新窗口没有文档属性,所以我不能在那里写一些 HTML。新窗口我需要预览输出数据:

  print(){
    let win = window.open();

    console.log(win);
  }

new window properties 我需要这样的东西

let win = window.open();
win.document.write('Some Data');
win.print()
win.close()

我该如何解决这个问题?有任何想法吗?

最佳答案

我已经解决了这个问题。我的解决方案:创建打印 View 组件并仅使用 window.print() 打印数据。

关于javascript - React + Electron 如何打印 HTML?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43202566/

相关文章:

javascript - 2d html5 Canvas 碰撞,howto

javascript - 映射到发送 props ReactJs

javascript - window.alert() 后无法编辑输入文本字段

javascript - 避免形式 -Angular js 中的默认警告

javascript - html页面中的div没有完全显示其内容

javascript - 将变量移动到第二个组件并保存在状态中

javascript - 从平面文件保存和加载 html 输入

node.js - npm 错误!安装 Electron 打包器

javascript - 许多复选框切换显示/隐藏

javascript - 从其他组件使用 setState 调用函数