在electron打包后出现无法载入本地视频与图片问题,是electron的跨域存在问题
解决方法如下:
在electron中的启动文件中(通常是background.js或main.js)找到BrowserWindow()
添加webSecurity: false解决跨域限制
如:
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
webSecurity: false,
contextIsolation: false,
nodeIntegration: true,
preload: __dirname + '/preload.js'
}
})