ElectronJS - 无法获得未定义的 属性 'join'
ElectronJS - Cannot get property 'join' of undefined
我正在尝试创建一个从托盘运行的应用程序。
不幸的是,我不断收到以下错误:
Uncaught TypeError: Cannot read property 'join' of undefined
我该如何解决这个问题?
我的main.js如下:
const { app, Menu, BrowserWindow, Tray, systemPreferences } = require('electron');
const { path } = require('path');
let tray = null;
try {
require('electron-reloader')(module)
} catch (_) { }
app.on('ready', () => {
tray = new Tray(getIcon());
if (process.platform === 'win32') {
tray.on('click', tray.popUpContextMenu);
}
setMenu();
tray.setToolTip('Student Eye');
});
const getIcon = () => {
if (process.platform === 'win32') {
return path.join(__dirname, './icon_light.png');
}
return path.join(__dirname, './icon_dark.png');
}
const openStatusWindow = () => {
const window = new BrowserWindow({
width: 800, height: 600, icon: 'icon_default.png', webPreferences: {
enableremotemodule: true,
nodeIntegration: true
}
})
window.loadURL(`file://${__dirname}/index.html`)
}
const setMenu = () => {
const menu = Menu.buildFromTemplate([
{
label: 'Status',
click() { openStatusWindow(); }
},
{
label: 'Quit',
click() { app.quit(); }
}
]);
tray.setContextMenu(menu);
}
const path = require('path');
没有
const { path } = require('path');
我正在尝试创建一个从托盘运行的应用程序。
不幸的是,我不断收到以下错误:
Uncaught TypeError: Cannot read property 'join' of undefined
我该如何解决这个问题?
我的main.js如下:
const { app, Menu, BrowserWindow, Tray, systemPreferences } = require('electron');
const { path } = require('path');
let tray = null;
try {
require('electron-reloader')(module)
} catch (_) { }
app.on('ready', () => {
tray = new Tray(getIcon());
if (process.platform === 'win32') {
tray.on('click', tray.popUpContextMenu);
}
setMenu();
tray.setToolTip('Student Eye');
});
const getIcon = () => {
if (process.platform === 'win32') {
return path.join(__dirname, './icon_light.png');
}
return path.join(__dirname, './icon_dark.png');
}
const openStatusWindow = () => {
const window = new BrowserWindow({
width: 800, height: 600, icon: 'icon_default.png', webPreferences: {
enableremotemodule: true,
nodeIntegration: true
}
})
window.loadURL(`file://${__dirname}/index.html`)
}
const setMenu = () => {
const menu = Menu.buildFromTemplate([
{
label: 'Status',
click() { openStatusWindow(); }
},
{
label: 'Quit',
click() { app.quit(); }
}
]);
tray.setContextMenu(menu);
}
const path = require('path');
没有
const { path } = require('path');