Failed to load module script: The server responded with a non-JavaScript MIME type of “text/plain“.

编程知识 行业动态 更新时间:2024-06-13 00:17:50

flask 使用es6语法中 type='module' 报错

报错如下:

Failed to load module script: The server responded with a non-JavaScript MIME type of “text/plain”. Strict MIME type checking is enforced for module scripts per HTML spec.

解决办法

在flask中添加代码:

import mimetypes
# 防止es6语法报错
mimetypes.add_type("application/javascript", ".js", True)

举例

文件结构(在同一个文件夹下)

更多推荐

Failed to load module script: The server responded with a non-JavaScript MIME ty

本文发布于:2023-03-25 20:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/800a9a9262b3c78a520230c60e22d7de.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:script   server   module   Failed   load

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!