fansleep
2021-06-04 21:42
采纳率: 50%
浏览 16

electron console报错:实在找不出问题在哪?

index.js

const { app, BrowserWindow } = require('electron')
function createWindow () {
       win = new BrowserWindow({
           webPreferences: {nodeIntegration: true, NodejsenableRemoteModule: true, contextIsolation: false},
       })
    win.on('ready-to-show',()=> {
        win.show()
    })
 
      win.loadFile('index.html')
      win.on('closed',()=>{
             console.log('closed')
             win = null
      })
} 
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'
app.on('ready', createWindow)
app.on('window-all-closed',()=>{
       console.log('window-all-closed')
       if(process.platform !== 'darwin') {
          app.quit()
       }
})
app.on('activate',() =>{
       console.log('activate')
       if(win == null) {
             createWindow()
       }
})

index.html

<!DOCTYPE html>
<html>
  <head>
           <meta charset="UTF-8">
           <title>绿色</title>
            <script src="event.js"></script>
  </head>
   <body>
          <img src="H:/源图/led.jpg"/>
          <h2>书名:<i>《绿色的树叶》</i></h2>
          <br>
          <br>
          出版社:<u>人民日报</u>
          <br>
          <br>
          原价:<del>188</del>元  促销价:66元
          <br>
          <br>
      <button id="button" onclick="onClick()">进入锁定模式</button>
  </body>
</html>

event.js

const remote = require("electron").remote
function onClick() {
    const button = document.getElementById('button')
    const win = remote.getCurrentWindow()
    if(win.isKiosk()){
     win.setKiosk(false)
     button.innerText = "进入锁定模式"
    }
    else{
        win.setKiosk(true)
        button.innerText = "退出锁定模式"
    }
}
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • fansleep 2021-06-13 21:44
    已采纳

    问题解决了

    点赞 打赏 评论

相关推荐 更多相似问题