Home > front end >  Quit Electron from VueJs
Quit Electron from VueJs

Time:09-23

I am using vue-cli-electron-builder. So how I can quit the application from a button in vue. Thanks.

CodePudding user response:

In your script tag you may create a button on your page and give it an event listener like:

window.close()

or

app.exit(0)

CodePudding user response:

Try that

// In your renderer process
const {ipcRenderer} = require('electron');
const closeApp = document.getElementById('closeApp');
closeApp.addEventListener('click', () => {
    ipcRenderer.send('close-me')
});

// In your app main process
const {ipcMain} = require('electron')
ipcMain.on('close-me', (evt, arg) => {
  app.quit()
})
  • Related