反应项目内部的 TweenLite 在构建后无法正常工作

TweenLite inside of react project not working after build

我在生产版本中遇到问题,GSAP TweenLite 插件无法正常工作并抛出错误 Uncaught TypeError: Failed to execute 'scrollTo' on 'Window': parameter 1 ('options') is not an object.。我的本地开发服务器似乎工作正常。

本地: console.log(com.greensock.plugins.ScrollToPlugin.version); -> //1.9.2

生产 console.log(com.greensock.plugins.ScrollToPlugin.version); -> //Uncaught TypeError: Cannot read property 'version' of undefined at <anonymous>:1:50

devDependencies "gsap": "^2.1.3",

组件:

import { TweenLite } from "gsap/all";
..

const handleOnClick = id => {
    let headerHeight = 90; // height of the sticky nav
    let paddingTop = 20; // add some padding.
    TweenLite.to(window, 0.5, { scrollTo: { y: `#${id}`, offsetY: headerHeight + paddingTop } });
};

//Map function
...
<li key={item.id} onClick={() => handleOnClick(item.id)}>
    <span className="text">{item.text}</span>
    ...
</li>
...

Greensock 论坛的回答:https://greensock.com/forums/topic/23806-tweenlite-inside-of-react-project-not-working-after-build/?do=findComment&comment=112883

import { TweenLite, ScrollToPlugin } from "gsap/all";
const plugins = [ScrollToPlugin];