本文介绍了ScrollMagic 与 React的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让 ScrollMagic 使用 ES2015 导入和 React.我收到此错误:

I'm trying to get ScrollMagic working with ES2015 import and React. I'm getting this error:

ERROR in ./~/scrollmagic/scrollmagic/uncompressed/plugins/animation.gsap.js
Module not found: Error: Cannot resolve module 'TimelineMax' in /Users/dillonraphael/Desktop/marbleshark_landingpage/node_modules/scrollmagic/scrollmagic/uncompressed/plugins
 @ ./~/scrollmagic/scrollmagic/uncompressed/plugins/animation.gsap.js 31:2-61

这就是我导入所有内容的方式.

This is how I'm importing everything.

import {gsap, TimelineMax, TweenMax} from 'gsap';
import ScrollMagic from 'ScrollMagic';
require('scrollmagic/scrollmagic/uncompressed/plugins/animation.gsap');

推荐答案

使用这个 import 语句对我有用:

Using this import statement works for me:

import * as ScrollMagic from 'scrollmagic'

使用 npm install scrollmagic 安装软件包后.

after installing the package with npm install scrollmagic.

这篇关于ScrollMagic 与 React的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 20:55