gpt4 book ai didi

javascript - 包含脚本在 web.py 中不起作用

转载 作者:行者123 更新时间:2023-11-28 21:21:21 26 4
gpt4 key购买 nike

大家。我想在 html 中包含 javascript(webpy 模板),但它不起作用。html 中的 javascript 代码运行得很好...

以下是主要的Python文件(main.py):

urls = ('/main','main')
render = web.template.render('templates/')

class main:
def GET(self):
return render.main()

app = web.application(urls,globals())

if __name__ == "__main__":
app.run()

模板/main.htm:

<body>
<script type="text/javascript" src="include.js"></script>
<script>
alert(location.href); //this line works..
</script>
</body>

包含.js:

alert('test');  //this line doesn't work

最佳答案

您必须将 include.js 文件放在项目根目录的“static/js”目录中,并且 src 应为“static/js/include.js”。 js”。

关于javascript - 包含脚本在 web.py 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6289446/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com