English 中文(简体)
解决导入 ScrollSmoother 失败
原标题:Failed to resolve import ScrollSmoother
It says it failed to resolve import ScrollSmoother thats my code : import gsap from "gsap" import ScrollTrigger from gsap/ScrollTrigger ; import ScrollSmoother from "gsap/ScrollSmoother"; gsap.registerPlugin(ScrollTrigger,ScrollSmoother) <------- const Navbar = () => { return (
Hello world
) } export default Navbar thats what shows on my screen PS: iam using vite
问题回答
Please note that while you can use this CDN for trial purposes on your test projects, it s crucial not to deploy it in production. This CDN is intended for testing purposes only. "https://assets.codepen.io/16327/ScrollSmoother.min.js" Alternatively, you can use the following command to install the trial package using npm: npm install gsap-trial For more information about trial packages, you can visit the official GSAP documentation page at the following link: GSAP Installation Documentation
import { useEffect, useRef } from react ; import gsap from gsap ; const SmoothScroll = ({ children }) => { const wrapperRef = useRef(null); const contentRef = useRef(null); useEffect(() => { const wrapper = wrapperRef.current; const content = contentRef.current; const updateScroll = () => { gsap.to(content, { y: -wrapper.scrollTop, ease: power1.out , overwrite: auto , }); }; wrapper.addEventListener( scroll , updateScroll); updateScroll(); return () => { wrapper.removeEventListener( scroll , updateScroll); }; }, []) return (
{children}
)}; We can use it by importing on any page and wrapping content around it.




相关问题
How to use one react app into another react app?

I have two react apps, parent app and child app. and child app have an hash router. I have build the child app using npm run build, It creates build folder. That build folder moved into inside the ...

how to get selected value in Ant Design

I want to print the selected value, and below is my option list: const vesselName = [ { value: 0 , label: ALBIDDA , }, { value: 1 , label: ALRUMEILA , }, { value: 2 ,...

How to add a <br> tag in reactjs between two strings?

I am using react. I want to add a line break <br> between strings No results and Please try another search term. . I have tried No results.<br>Please try another search term. but ...

热门标签