[英]Eel python: Javascript error eel is not a function
我正在使用 eel 與 python 進行通信。 我在目錄C:\Users\Desktop\Eel
工作,其中我有app.py
,在UI
文件夾中我有index.html, myjava.js, style.css, images
eel.js
我這么說是因為在文檔中它說要包含名為/eel.js
的腳本。
索引.html
<head>
<script type="text/javascript" language="JavaScript" src="./myjava.js"></script>
<script type="text/javascript" src="/eel.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container" onclick="runeel()">
</body>
我的 Javascript 是:
function runeel(){
eel.runpy()
}
應用程序.py
import eel
eel.init('UI')
eel.start('index.html', size=(900, 550))
@eel.expose
def runpy():
....code which creates an excel file in desktop...
當我運行 py 文件時, index.html 會加載,然后當我單擊 div 時,我會進入 function ,但它會引發錯誤:
myjava.js:2 Uncaught TypeError: eel.runpy is not a function
我錯過了什么?
好像是先寫了init語句。 在 import 語句之后寫 @eel.expose 語句怎么樣?
我不擅長英語,所以我擔心它會有意義。 但如果我能提供幫助,我會很高興。
在我從 /eel.js 中刪除之前,我遇到了同樣的問題
<script type="text/javascript" src="/eel.js"></script>
現在看起來像
<script type="text/javascript" src="eel.js"></script>
在我的情況下,我必須在通過裝飾器暴露 function后開始eel
:
import eel
eel.init('UI')
@eel.expose
def runpy():
....code which creates an excel file in desktop...
eel.start('index.html', size=(900, 550))
嘗試這個:
import eel
eel.init('UI')
eel.start('index.html', size=(900, 550))
@eel.expose()
def runpy():
....code which creates an excel file in desktop...
我改變了什么? 我將 () 添加到 @eel.expose
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.