TweenLite 打字稿导入

TweenLite Typescript import

我通过 npm 下载了 GSAP 包,现在我想通过 TypeScript 将 TweenLite class 导入我的应用程序。可以通过写入 require('gsap'); 导入所有 GSAP 来完成,并且效果很好。但在 TypeScript 中它不起作用。 我想这样做:import TweenLite from 'gsap';.

可能吗?

找到答案 here. Actually if you want to do this then you need write definitions for library. The answer from the link provide link to git repository that contains what I was needed. You can find it here

npm install --save-dev gsap
npm install --save-dev @types/gsap

在你的 ts 文件中,导入 gsap

import {TweenLite} from "gsap";

在你的方法中你可以写

let photo = document.getElementById("photo");
TweenLite.to(photo, 2, {width:"200px", height:"550px"});

如果您有 div 和身份证照片