Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

293
Views
Electron App Salga inmediatamente después de imprimir el comando

Estoy tratando de crear una aplicación de escritorio que pueda imprimir después de hacer clic en algún botón. así que aquí está mi código.

principal.js

 const {app,BrowserWindow} = require('electron'); function createWindow(){ const win = new BrowserWindow({ resizable:false }) win.maximize() win.removeMenu() win.loadFile("./index.html") win.webContents.on('did-create-window',(window,detail)=>{ window.removeMenu() window.resizable = false window.webContents.print({silent:false}) }) } app.whenReady().then(() => { createWindow() app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) { createWindow() } }) }) app.on('window-all-closed', () => { if (process.platform !== 'darwin') { app.quit() } })

índice.html

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> whatever <button onclick="newPrint()">BIGGIE</button> </body> <script> function newPrint(){ var myWindow = window.open("", "MsgWindow", "width=200,height=100"); myWindow.document.write("<p>This is 'MsgWindow'. I am 200px wide and 100px tall!</p>"); } </script> </html>

paquete.json

 { "name": "electron-print", "version": "1.0.0", "description": "", "main": "main.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "electron": "^19.0.2" } }

ingrese la descripción de la imagen aquí

Entonces, después de hacer clic en el botón, ¡la aplicación de electrones se cerró repentinamente! Simplemente no sé por qué sucedió.

e intenté volver a crear esta aplicación en otra computadora (la mía estaba ejecutando Win 11 y pensé que tal vez ese era el problema) ¡y funcionó bien!

¿Será que Electron aún no es totalmente compatible con Win 11?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Esto se parece mucho a este error de Electron , que se solucionó en Electron 19.0.2, en el que aparentemente estás.

¿Puede reinstalar sus módulos de nodo para confirmar que todavía ve el problema en 19.0.2? Este problema habría estado presente en Electron 19.0.1.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!