【发布时间】:2019-10-21 23:56:48
【问题描述】:
我正在使用 Vue CLI 3 和 vue-cli-plugin-electron-builder 打包我的 Vue Electron 应用程序,但我无法让我的 preload.js 脚本用于电子工作。
主窗口
win = new BrowserWindow({
width: 800,
height: 600
webPreferences: {
nodeIntegration: false,
preload: path.join(__dirname, "/../src/preload.js") // works but window.electron.dialog in undefined
}
});
preload.js
const { dialog } = require("electron");
window.electron = {};
window.electron.dialog = dialog;
window.electron.dialog 在我的 Vue 组件中始终未定义 - 导入显然不起作用。请注意,window.electron 已正确定义。我一定是错过了什么。
【问题讨论】:
标签: vue.js electron vue-cli-3 electron-builder