预加载脚本未加载到electron@5.0.0浏览器视图中 [英] Preload script not loading in electron@5.0.0 browserview

查看:75
本文介绍了预加载脚本未加载到electron@5.0.0浏览器视图中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在浏览器视图中加载预加载脚本.根据文档,浏览器视图接受与浏览器窗口接受的参数相同的参数.但是预加载脚本不会被加载到视图中,控制台中也不会显示错误消息.

I tried loading a preload script inside browserview. According to the documentation browserview accepts the same arguments as the browserwindow accepts. But the preload script not gets loaded in the view, not either an error message in the console.

我检查了新进程的命令行,该命令行也未显示预加载参数.谁能帮助我确定问题出在哪里?

I inspected the command line of the new process, which also does not show a preload arguments. can anyone help me identifying where it went wrong?

电子版本:5.0.0,5.0.1也不起作用作业系统版本:Windows 10 x64

Electron version: 5.0.0 , 5.0.1 also not working OS version : Windows 10 x64

this.ElectronService.remote.BrowserView({ webPreferences: { preload : 'assets/preload/sample.js', nodeIntegration : false , plugins : false } })

推荐答案

我在预加载脚本文件中使用了绝对路径,当在angular/typescript中使用时,它与相对路径不起作用.

I used absolute path for preload script file , It doesnt work with relative path, when used inside angular/typescript.

preload : path.join(__dirname, '/assets/preload/sample.js')

这篇关于预加载脚本未加载到electron@5.0.0浏览器视图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆