如何解决如何使用GSAP获取JS文件以使代码动画化? 使用模块教程加载GSAP:
我是js编码的新手,正在尝试使用GSAP为某些代码制作动画。我无法移动或执行任何功能。编译文件时没有任何错误。另外,我无法在我的CodePen上制作任何动画,我一直试图使用它来查看我是否可以尝试做可能有用的任何事情。我的HTML和CSS工作正常。我不知道可能是什么问题?
CodePen:
https://codepen.io/ashleynw1800/pen/VwaRGBX
HTML:
minutes = input(":")
if minutes >= "1":
#Minutes Calculation
minsec = str(int(eval(minutes) * 60))
#Shutdown with time
os.system("shutdown.exe /s /t " + minsec)
CSS:
<!-- Font Awesome-->
<script src="https://kit.fontawesome.com/3c79b583ac.js" crossorigin="anonymous"></script>
<!-- Google Fonts-->
<link href="https://fonts.googleapis.com/css2?family=Abril+Fatface&display=swap" rel="stylesheet">
<section class="section-1">
<div id="hello-container">
<h1 class="hello"> hello!</h1>
</div>
<div id="happy-container">
<i class="fa fa-smile-o" aria-hidden="true"></i>
</div>
</section>
JS(我已经全力以赴,除了一条基本的线试图使任何东西都可以工作):
/* =============
Demo
============= */
.section-1{
display: grid;
grid-template-areas: ". hello happy .";
grid-template-columns: "auto 2fr 1fr auto";
background-color: #E6EBFF;
}
#hello-container{
grid-area: hello;
align-self: center;
}
.hello{
font-size: 150px;
font-family: 'Abril Fatface',cursive;
color: #FF4F2D;
}
#happy-container{
grid-area: happy;
align-self: center;
color: #FF89FF;
font-size: 150px;
}
解决方法
“您的错误” ==>模块想法/概念的实现错误:
要从中导入的模块。这通常是相对或绝对路径 包含模块的.js文件的名称。 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#:~:text=To%20dynamically%20import%20a%20module,js')%20。
通过CDN
(Codepen)进行安装。 删除 import {gsap} from "gsap";
,该代码将正常运行。否则,您会收到此错误:
未捕获的TypeError:无法解析模块说明符“ gsap”
通常,检查代码并检查控制台错误非常有用。 https://developers.google.com/web/tools/chrome-devtools/console
相关文章
无法解析模块说明符 https://medium.com/@samichkhachkhi/failed-to-resolve-module-specifier-23fae20222df
使用模块教程加载GSAP:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。