简体   繁体   中英

Atom Electron Close and Minimize window using the html button and javascript

I stated using Electron and trying to make minimize and close button.

index.html

    <button id="minus" onclick="minimize()">minimize</span></button>
    <button id="close" onclick="close()">close</span></button>

index.js

const remote = require('electron').remote;

  function minimize(){
    var window = remote.getCurrentWindow();
    window.minimize();  
  }

  function close(){
    var window = remote.getCurrentWindow();
    window.close();  
  }

I must be doing some silly mistake or what but minimize button works perfectly while close button not working.

I also tried EventListener method as mentioned here Atom Electron - Close the window with javascript And it works perfectly, but why my function approach isn't working??

哦,我只是通过将close()函数的函数名称改为其他东西来解决这个问题,看起来close与其他函数或类似的东西相冲突。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM