javascript - 内联库未显示,“未捕获的语法错误:无法在模块外使用 import 语句”即使我添加了 type="module"
问题描述
未捕获的语法错误:无法在模块外使用 import 语句。
我已经尝试添加 type="module"。
<div class="d-flex justify-content-center">
<div id="inline-gallery-container" class="inline-gallery-container"></div>
</div>
<script>
import lgZoom from "https://cdn.skypack.dev/lightgallery@2.0.0-beta.3/plugins/zoom";
import lgThumbnail from "https://cdn.skypack.dev/lightgallery@2.0.0-beta.3/plugins/thumbnail";
const $lgContainer = document.getElementById("inline-gallery-container");
const inlineGallery = lightGallery($lgContainer, {
container: $lgContainer,
dynamic: true,
hash: false,
closable: false,
showMaximizeIcon: true,
appendSubHtmlTo: ".lg-item",
slideDelay: 400,
plugins: [lgZoom, lgThumbnail],
dynamicEl: [
{
src: 'hexagon.jpg',
thumb: 'hexagon.jpg',
subHtml: `<div class="lightGallery-captions">
<h4>Caption 1</h4>
<p>Description of the slide 1</p>
</div>`,
},
{
src: 'landscape.jpg',
thumb: 'lanscape.jpg',
subHtml: `<div class="lightGallery-captions">
<h4>Caption 2</h4>
<p>Description of the slide 2</p>
</div>`,
},
{
src: 'hillsong-united-aftermath.jpg',
thumb: 'hillsong-united-aftermath.jpg',
subHtml: `<div class="lightGallery-captions">
<h4>Caption 2</h4>
<p>Description of the slide 2</p>
</div>`,
},
],
thumbWidth: 60,
thumbHeight: "40px",
thumbMargin: 2
});
setTimeout(() => {
inlineGallery.openGallery();
}, 200);
</script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js"
integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.min.js"
integrity="sha384-Atwg2Pkwv9vp0ygtn1JAojH0nYbwNJLPhwyoVbhoPwBhjQPR5VtM2+xf0Uwh9KtT" crossorigin="anonymous"></script>
..................................................... ..................................................... ..................................................... ................................................“新手“………………………………………………………………………………………………………………………………………………………………………… ..................................................... ..................................................... ..................................................... ...................................
解决方案
推荐阅读
- android - 用户关闭位置权限后,如何在 Android 10 中再次请求位置权限?
- jenkins - Jenkins 在拉取图像时添加了私有注册 URL 标签
- swiftui - 如何在 SwiftUI 中显示文本 2 秒然后将其隐藏?
- java - 如何使用具有多个对象类型(如字符串、对象、布尔值)的“回复”之类的单个键。我正在尝试解析它以填充 Recyclerview
- python - 使用带有 tkinter 的 Telethon 连接到电报而不冻结 GUI
- kubernetes - 在 Traefik Kubernetes Ingress 中打开 HTTP 和 HTTPS 以外的其他端口
- github - 如何删除没有设置图标的 GitHub 存储库
- python - 全局“关键位置”变量上的 NameError 和 ax.cla() 主要减慢速度 - Matplotlib,Python
- r - 如何强制在 R 中显示所有 y 轴值?
- cmake - 明确告诉 CMake target_link_libraries() 将依赖项读取为目标而不是系统路径中的文件?