简体   繁体   中英

Import JS to HTML 404

在此处输入图片说明 Could someone help me figure out why this import is not working? Even when I do script/import.js it will not work. I am getting this error message: 127.0.0.1 - - [09/Sep/2020 15:09:35] "GET /import.js HTTP/1.1" 404. Given the file structure in attached image... what am I missing :D

您想访问位于当前文件夹上一级文件夹中的文件夹中的文件,因此您应该执行以下操作:

<script src="../script/import.js"></script>

I'm assuming that you are using Flask for your app, in which case you will need to serve your javascript files as 'static' files, see: https://flask.palletsprojects.com/en/1.1.x/tutorial/static/

Move your 'script' folder into a new folder called 'static', then change your script import to:

<script type="text/javascript" src="{{ url_for('static', filename='script/import.js') }}"></script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM