Django 中的 Javascript 模块管理已关闭

问题描述

我正在处理一个包含多个 .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="./">

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...