3

我正在开发一个具有多个 .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



4

1 回答 1

2

尝试将基本 href 更改index.html为当前目录

改变这个

<base href="/">

对此

<base href="./">
于 2021-03-01T07:35:03.547 回答