大家。我想在html(webpy模板)中包含javascript,但它不起作用.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>
include.js:
alert('test'); //this line doesn't work
答案 0 :(得分:3)
您必须将include.js
文件放在项目根目录下的“static / js”目录中,src
应为“static / js / include.js”。