我正在尝试使用机车卷轴,但出现错误
我尝试使用 react-locomotive-scroll 但得到同样的错误
我的_app.tsx
长相是这样的
我的错误在哪里?我尝试将包含整个页面的布局组件放入其中,但它也不起作用
import type { AppProps } from "next/app";
import { ThemeProvider, Global } from "@emotion/react";
import { theme } from "../src/common/theme";
import { globalStyles } from "../src/styles/global";
import { appWithTranslation } from "next-i18next";
import "locomotive-scroll/dist/locomotive-scroll.css";
import { useEffect } from "react";
function MyApp({ Component, pageProps }: AppProps) {
useEffect(() => {
let scroll;
import("locomotive-scroll").then((locomotiveModule) => {
scroll = new locomotiveModule.default({
el: document.querySelector("[data-scroll-container]"),
smooth: true,
smoothMobile: false,
resetNativeScroll: true,
});
});
// `useEffect`'s cleanup phase
return () => scroll.destroy();
});
return (
<ThemeProvider theme={theme}>
<Global styles={globalStyles(theme)} />
<Component {...pageProps} data-scroll-container />
</ThemeProvider>
);
}
export default appWithTranslation(MyApp);
我也用next-transpile-modules
const withTM = require("next-transpile-modules")(["gsap", "locomotive-scroll"]);