首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >打印后电子崩溃

打印后电子崩溃
EN

Stack Overflow用户
提问于 2020-09-16 12:02:46
回答 1查看 494关注 0票数 1

我有一段代码,可以打开一个新的弹出窗口并触发打印。打印工作正常,但当我关闭弹出窗口时,应用程序崩溃,并从我的终端错误显示"This is probably not a problem with npm. There is likely additional logging output above.

代码语言:javascript
运行
复制
var img = jQuery("#imgWrap").html();
var popup = window.open();
console.log(popup);
popup.focus();
popup.document.write(img);
popup.print();

下面是完整的日志记录输出

代码语言:javascript
运行
复制
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start'
1 verbose cli ]
2 info using npm@6.14.8
3 info using node@v14.11.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle electron-photobooth@1.0.0~prestart: electron-photobooth@1.0.0
6 info lifecycle electron-photobooth@1.0.0~start: electron-photobooth@1.0.0
7 verbose lifecycle electron-photobooth@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle electron-photobooth@1.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\a_bee\Documents\apps\ElectronPhotobooth\node_modules\.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\TortoiseSVN\bin;C:\Program Files\nodejs\;C:\Users\a_bee\AppData\Local\Microsoft\WindowsApps;;C:\Users\a_bee\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\a_bee\AppData\Roaming\npm
9 verbose lifecycle electron-photobooth@1.0.0~start: CWD: C:\Users\a_bee\Documents\apps\ElectronPhotobooth
10 silly lifecycle electron-photobooth@1.0.0~start: Args: [ '/d /s /c', 'electron .' ]
11 silly lifecycle electron-photobooth@1.0.0~start: Returned: code: 3221226505  signal: null
12 info lifecycle electron-photobooth@1.0.0~start: Failed to exec start script
13 verbose stack Error: electron-photobooth@1.0.0 start: `electron .`
13 verbose stack Exit status 3221226505
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:314:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:314:20)
13 verbose stack     at maybeClose (internal/child_process.js:1047:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid electron-photobooth@1.0.0
15 verbose cwd C:\Users\a_bee\Documents\apps\ElectronPhotobooth
16 verbose Windows_NT 10.0.18363
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v14.11.0
19 verbose npm  v6.14.8
20 error code ELIFECYCLE
21 error errno 3221226505
22 error electron-photobooth@1.0.0 start: `electron .`
22 error Exit status 3221226505
23 error Failed at the electron-photobooth@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 3221226505, true ]
EN

回答 1

Stack Overflow用户

发布于 2020-09-17 23:59:15

我对此有点纠结,所以我试着改变我正在使用的Electron的版本。在Electron 9.3.1上,它使用以下代码工作:

代码语言:javascript
运行
复制
const electron = require('electron');
const BrowserWindow = electron.remote.BrowserWindow; 
let win = BrowserWindow.getFocusedWindow();

function print(){
   win.webContents.print({}, function(response){
     console.log(response);
   });
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63912937

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档