Tweenlite를 사용하려고합니다. 간단하지만, 저에게는 그렇지 않습니다. 내 탐색 모음에 내 index.js에서 toScroll이라는 함수를 전달하려고하고 있는데 onClick을 사용하여 호출 할 때 스크롤 할 ID를 전달하려고합니다. 누구든지 나를 도울 수 있다면 크게 감사하겠습니다. 함수가 탐색 막대를 통과하고 있지만 오류가 발생합니다.Greensock Tweenlite를 사용하여 스크롤하기 React
bundle.js:160 Uncaught TypeError: _gsap2.default.to is not a function
at App.toScroll (bundle.js:160)
at onClick (bundle.js:20987)
at Object.ReactErrorUtils.invokeGuardedCallback (bundle.js:4679)
at executeDispatch (bundle.js:4479)
at Object.executeDispatchesInOrder (bundle.js:4502)
at executeDispatchesAndRelease (bundle.js:3932)
at executeDispatchesAndReleaseTopLevel (bundle.js:3943)
at Array.forEach (<anonymous>)
at forEachAccumulated (bundle.js:4779)
at Object.processEventQueue (bundle.js:4148)
하는 index.js :
이
는 내가 점점 오전 오류가 오류를 바탕으로class App extends Component {
constructor(props) {
super(props);
this.toScroll = this.toScroll.bind(this);
}
toScroll(location) {
console.log(location)
TweenLite.to(window, .8, {scrollTo: location});
}
render() {
return (
<div>
<Header toScroll={this.toScroll} />
<Intro id="intro" />
<WhatIDo id="what" />
<WhoIAm id="who" />
<Gallery id="gallery" />
<Contact id="contact" />
<Footer />
</div>
);
}
}
header.js (탐색 모음)
const header = (props) => {
console.log(props.toScroll);
return (
<HeaderContainer>
<HeaderName>
xxxx xxxxxxx
</HeaderName>
<HeaderLinks>
<List>
<Item onClick={() => props.toScroll("intro")}>Intro</Item>
<Item onClick={() => props.toScroll("what")}>What I do</Item>
<Item onClick={() => props.toScroll("who")}>Who I am</Item>
<Item onClick={() => props.toScroll("gallery")}>My Work</Item>
<Item onClick={() => props.toScroll("contact")}>Contact</Item>
</List>
</HeaderLinks>
</HeaderContainer>
);
}