0
我嘗試通過npm start
啓動我的電子應用程序後遇到以下錯誤。這裏的錯誤消息:TypeError:無法讀取undefined屬性'setZoomLevelLimits'
TypeError: Cannot read property 'setZoomLevelLimits' of undefined
下面是代碼:
const electron = require("electron").webFrame.setZoomLevelLimits(1, 1);
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
let mainWindow;
app.on("ready", function(){
mainWindow = new BrowserWindow({
width: 800,
height: 600,
frame: false,
kiosk: true
});
mainWindow.loadURL("file://" + __dirname + "/index.html");
// Debug3
// mainWindow.openDevTools({ detach: true });
});
我試圖阻止用戶的拖放在我的桌面應用程序的屏幕縮放和website-user-drag: none
不工作,以及因爲這樣:
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
謝謝你的回答。那麼你的解決方案是什麼? – John
@John你需要在渲染過程中調用'require(「electron」)。webFrame.setZoomLevelLimits(1,1)'',你可以在'index.html'中的'