- electron、electron-packager慢的问题
export ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/
export ELECTRON_CUSTOM_DIR=<CURRENT_VERSION>
- js 不运行
Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-0ueXKeM6/XPcQ+fZ5z5+evQaq4i+TxvOonmAh2jjDJM='), or a nonce ('nonce-...') is required to enable inline execution.
修改html 代码
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src * 'unsafe-inline'">
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src * 'unsafe-inline'">
- 引入 jquery
<script>window.$ = window.jQuery = require("./js/jquery-3.5.1.min")</script>
- html require 出错
nodeIntegration: true
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
preload: path.join(__dirname, 'preload.js')
}
})
- 开启浏览器调试模式
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
preload: path.join(__dirname, 'preload.js')
}
})
mainWindow.webContents.openDevTools()
然后就可以开心地搞html啦!!!








网友评论