问题描述
我正在处理一个包含多个 .js 文件以包含不同功能的项目。 我想在 M2.js 中使用 M1.js 中的函数,我正在做的是从 M1.js 导出函数并在 M2.js 中导入。
导出工作正常,但问题是当我导入函数时。
M1.js
--export {function}
M2.js
--import {function} from './M1.js'
<script type="module" href="{% static 'myapp/M1.js'%}
<script type="module" href="{% static 'myapp/M2.js'%}
Loading module from “app.com/static/Invoicing/exif_js” was blocked because of a disallowed MIME type (“text/html”).
我的目录结构是
-Project
|--project
|--Invoicing (App)
|--static
|--Invoicing
|--M1.js
|--M2.js
|--templates
|--etc
|--static
|--etc
解决方法
尝试将 index.html
中的基本 href 更改为当前目录
改变这个
<base href="/">
到这里
<base href="./">