GSAP - Javascript:说明符“gsap/dist/gsap”是一个裸露的说明符,但没有重新映射到任何东西

问题描述 投票:0回答:1

我正在尝试在 Web 项目中使用 JavaScript GSAP 库(在 Python Flask 框架上运行)。我有这个

animate.js
脚本,内容如下:

import { gsap } from "gsap/dist/gsap";
    
import { ScrollTrigger } from "gsap/dist/ScrollTrigger";
import { MotionPathPlugin } from "gsap/dist/MotionPathPlugin";
import { TextPlugin } from "gsap/dist/TextPlugin";


gsap.registerPlugin(ScrollTrigger,MotionPathPlugin,TextPlugin);

我从 GSAP 安装文档生成了上述内容作为 UMD(通用模块定义)导入。但是,当我尝试运行该脚本(在 Firefox 上)时,出现此错误

Uncaught TypeError: The specifier “gsap/dist/gsap” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”.

我尝试在 UMD 和 ESM 导入之间切换,但仍然收到相同的错误消息。我需要帮助理解异常消息以及如何解决错误。

javascript flask ecmascript-6 gsap umd
1个回答
0
投票

试试这个

import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import { MotionPathPlugin } from "gsap/MotionPathPlugin";
import { TextPlugin } from "gsap/TextPlugin";

gsap.registerPlugin(ScrollTrigger, MotionPathPlugin, TextPlugin);
© www.soinside.com 2019 - 2024. All rights reserved.