我一直在嘗試在 Electron 應用程序的 HTML 中使用語義 UI。我可以加載元素,但由于某種原因無法使用 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> <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>
1 回答

喵喔喔
TA貢獻1735條經驗 獲得超5個贊
在你的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
}
})
- 1 回答
- 0 關注
- 141 瀏覽
添加回答
舉報
0/150
提交
取消