我想在我的 nextjs 应用程序中使用 locomotive-scroll 美化我的项目。但我不断收到错误文档未定义。我该如何解决这个问题?
简而言之,这是我需要知道的。
从现在开始谢谢你!
import React, { useEffect } from "react";
import locomotiveScroll from "locomotive-scroll";
function App() {
const scrollRef = React.createRef();
useEffect(() => {
const scroll = new locomotiveScroll({
el: scrollRef.current,
smooth: true
});
});
return (
<div className="scroll" ref={scrollRef}>
<h1 data-scroll data-scroll-speed="3" data-scroll-position="top">
Locomotive Scroll in React
</h1>
</div>
);
}