将电子从 4.1.4 升级到 5.0.0 后,出现此错误
阻止了来源为“file://”的框架访问跨源框架。在 HTMLIFrameElement.preload (renderer.js:31:78)
我new BrowserWindow({ webPreferences })按此处添加,但此错误仍然存在。
这是我的 index.html
<html>
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
</head>
<body>
<iframe data-bind="visible: showIframe, attr:{src:appUrl}" allow="autoplay; geolocation; microphone; camera" allowfullscreen></iframe>
</body>
<script>
require('./renderer.js');
</script>
</html>
Run Code Online (Sandbox Code Playgroud)
这是 main.js 中的一些代码
const {
autoUpdater
} = require('electron-updater');
const platform = require('os').platform();
const electron = require('electron');
const fs = require('fs-extra');
const CronJob = require('cron').CronJob;
const {
app,
BrowserWindow,
Tray,
Menu,
ipcMain
} = electron;
const path …Run Code Online (Sandbox Code Playgroud) 我想知道browser-window的当前 URL 。有没有办法访问 BrowserWindow 的 window.location.href 属性或任何其他方式来获取它?