fansleep 2021-06-04 21:42 采纳率: 0%
浏览 41
已采纳

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
    关注

    问题解决了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 什么设备可以研究OFDM的60GHz毫米波信道模型
  • ¥15 不知道是该怎么引用多个函数片段
  • ¥15 爬取1-112页所有帖子的标题但是12页后要登录后才能 我使用selenium模拟登录 账号密码输入后 会报错 不知道怎么弄了
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题