Using BrowserWindow.on ('close') in electron cannot prevent window closing

I loaded this listener in the created hook of the vue component:

($electron points to require ("electron"), which is a function of the vue-electron package)

created () {
    this.$electron.remote.getCurrentWindow.on("close", (e) => {
        e.preventDefault()
    }
}

according to the official document, e.preventDefault () will prevent the window from closing, but the window is still closed.

did not find the reason, what is the possible reason?

< hr >

the project is built with electron-vue template and runs in development mode

  • electron: 1.8.7
  • vue: 2.5.13
  • vue-router: 3.0.1

binds via remote, which is actually on the main process. Due to asynchronism, shutdown cannot be prevented during the rendering process. Block

with onbeforeload in the rendering process
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36c32-2c037.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36c32-2c037.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?