我試圖從 python 調用 javascript 函數來更改 DOM,但我無法做到。只需控制臺記錄一條消息就可以了,但是當我嘗試影響 DOM 時,我就會收到標題中提到的錯誤。我確信我在這里缺少一些基本的東西......有什么建議或解決方法嗎?app.pyapp = Flask(__name__)@app.route('/')def index(): return render_template("index.html")@app.route('/python_func')def python_func(): eval_res, jsFile = js2py.run_file('static/test.js') jsFile.hello() return "nothing"測試.jsfunction hello() { console.log("hello") <--- Works let div = document.createElement("div") <--- This doesn't}script.js(此按鈕調用python函數)$(function() { $('#startbtn').bind('click', function() { $.getJSON('/python_func', function(data) { //do nothing }); return false; });});
添加回答
舉報
0/150
提交
取消