JQuery不能与SemantiUI和Electron.js一起使用 [英] jQuery not working with SemanticUI and Electron.js

查看:0
本文介绍了JQuery不能与SemantiUI和Electron.js一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试为一款电子应用程序在我的HTML中使用语义用户界面。我可以加载元素,但由于某些原因不能使用jQuery。我已经尝试了我的本地jQuery副本:

<script src="node_modules/jquery/dist/jquery.min.js"></script>

和CDN版本:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

但似乎没有一个管用。我试过用jQuery做一些简单的事情,但仍然不起作用。任何帮助都将不胜感激。我更喜欢用我的本地复制品。

<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="utf-8">
      <title>Title</title>

      <link rel="stylesheet" type="text/css" href="semantic/dist/semantic.min.css">
      <!-- <script src="node_modules/jquery/dist/jquery.min.js"></script> -->
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
   </head>

   <body>
      <div class="ui sidebar inverted vertical menu">
         <a class="item">1</a>
      </div>

      <div class="pusher">
         <h1 class="asdf" id="asdf">Hello</h1>
      </div>


      <script>
         document.getElementById("asdf").innerHTML = "new1";
         $('#asdf').text("new2");
         $('#asdf').html("new2");
      </script>
      <script src="semantic/dist/semantic.min.js"></script>

   </body>

</html>

推荐答案

在您的index.html

  <head>
    <script>
      window.$ = window.jQuery = require("jquery");
    </script>
    ....

createBrowerWindow,其中nodeIntegration位于main.js

const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      nodeIntegration: true
    }
  })

这篇关于JQuery不能与SemantiUI和Electron.js一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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