jQuery 尝试在 electronJS 中嵌入视频时未定义

jQuery is not defined when trying to embed a video in electronJS

概览 我正在尝试在我的电子应用程序中嵌入视频。我的 main.js 脚本加载了一个名为 index.html 的页面。 index.htm 然后为页面的功能提供一个名为 app.js 的脚本。在app.js中,我嵌入了一些视频

for (let vid of shuffledVideos){
                try{
                    let cuurVid = await Video.findById(vid);
                    console.log(cuurVid)
            
                    let d = document.createElement('div');
                    d.classList.add("videoCard")
                    mediaDisp.append(d)
            
                    let i = document.createElement("iframe");
                    i.setAttribute("src", cuurVid.link)
                    i.setAttribute("allowfullscreen", "allowfullscreen")
                    i.setAttribute("width", "650")
                    i.setAttribute("height", "490")
                    i.setAttribute("frameborder", "0")
                    i.setAttribute("scrolling", "no")
                    d.append(i)
                }
                catch{
                    console.log(`Failed to create video: ${vid}.`)
                }
            }

运行时出现错误“Uncaught ReferenceError: jQuery is not defined at embed-en.js?2740:222”。我尝试了下面列出的一些方法。

我尝试过的事情

我已经尝试了 post 中的内容: 但也许我只是做错了。在 index.html 中的 body 标签末尾,我尝试这样做

    <script>window.$ = window.jQuery = require('jquery');</script>
    <script>
        require("../js/renderer.js")
    </script>

    <script src="../js/app.js"></script>

还有这个

    <script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
    <script type="text/javascript" src="./../js/jquery-3.6.0.min.js"></script>
        require("../js/renderer.js")
    </script>
    <script src="../js/app.js"></script>
    <script>if (window.module) module = window.module;</script>

并且都输出相同的错误。我还尝试了 npm 安装 jQuery 并通过

在 app.js 的顶部要求它
const jQuery= require("jquery")

感谢任何帮助。

我只是将 electron 降级到 nodeintegration 默认设置为 false 之前。