[英]fs.existsSync is not a function when importing electron
我目前正在使用 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 is not a function
您可以在創建主 BrowserWindow 時使用 webPreferences 中的 preload 參數。 在 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);
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.