2
當電子直接運行我的應用程序電子打包不允許加載本地資源
electron .
一切工作正常,但隨着電子包裝機包裝的應用程序,並運行它的時候,我得到的錯誤
Not allowed to load local resource
代碼
mainWindow.loadURL(`${__dirname}/../build/index.html`)
任何幫助
?
當電子直接運行我的應用程序電子打包不允許加載本地資源
electron .
一切工作正常,但隨着電子包裝機包裝的應用程序,並運行它的時候,我得到的錯誤
Not allowed to load local resource
代碼
mainWindow.loadURL(`${__dirname}/../build/index.html`)
任何幫助
?
此請求中缺少很多詳細信息。我總是使用path.resolve
來訪問你的本地文件,而不是你正在使用的插值。例如,如果您正在使用其正常的選項來設置電子,我會做一些事情,如:
var path = require('path');
var iconPath = path.resolve(__dirname, '../build/program.ico');
const appIcon = new Tray(iconPath);
mainWindow = new Window({
width: 1280,
height: 1024,
autoHideMenuBar: false,
useContentSize: true,
resizable: true,
icon: iconPath });
var indexPath = path.resolve(__dirname, '../build/index.html');
mainWindow.loadURL(indexPath);
這就是說,我的猜測是,你../build/index.html
路徑其實不是你的文件在地方。如果您沒有將發行版複製到您認爲正在複製它的位置(或複製失敗),則會發生此錯誤。