我正在尝试在 thymeleaf html 页面上使用PNotify在网络浏览器上显示一个简单的通知。
我已将以下 webjar 添加到我的 pom.xml 中。
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>pnotify__core</artifactId>
<version>${pnotify.version}</version>
</dependency>
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>pnotify__mobile</artifactId>
<version>${pnotify.version}</version>
</dependency>
PNotify 版本 = 5.2.0
在我的 HTML 中,我包含了 -
<link th:href="@{/webjars/pnotify__core/dist/PNotify.css}" rel="stylesheet" />
<link th:href="@{/webjars/pnotify__mobile/dist/PNotifyMobile.css}" rel="stylesheet" />
<script th:src="@{/webjars/pnotify__core/dist/PNotify.js}"></script>
<script th:src="@{/webjars/pnotify__mobile/dist/PNotifyMobile.js}"></script>
我已经确认所有这些资源都正确加载了 200 状态代码。在我的 javascript 中,我正在尝试执行以下操作 -
<script type="module">
import { defaultModules } from '../webjars/pnotify__core/5.2.0/dist/PNotify.js';
</script>
但是,我在浏览器控制台中收到以下错误
Uncaught SyntaxError: import not found: defaultModules
我通过检查浏览器确认该文件存在于 http://localhost:8080/webjars/pnotify__core/5.2.0/dist/PNotify.js
我一无所知,在论坛中找不到任何帮助。有人可以帮助我并分享一些调试指南吗?