我目前正在使用 Vue 和 Electron并想使用
重新启动应用程序import { app } from 'electron';
export default {
name: 'Home',
methods: {
restartApp() {
app.relaunch()
app.exit()
}
}
}
但是当我导入 Electron 时,我得到fs.existsSync is not a function
我也尝试过使用
const remote = require('electron');
import { app } from remote;
还有
const remote = window.require('electron')
返回我window.require不是一个函数
最佳答案
您可以在创建主浏览器窗口时使用 webPreferences 中的预加载参数。 在main.js中,
mainWindow = new BrowserWindow({
webPreferences: {
nodeIntegration: false,
preload: path.join(__dirname, 'preload.js')
}
})
在preload.js中
const remote = require("electron").remote;
window.appQuit = function() {
remote.app.exit(0);
};
关于javascript - 导入 Electron 时,fs.existsSync 不是一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58059092/