Home > database >  How do I fix: "Uncaught TypeError: Cannot read properties of undefined (reading 'init'
How do I fix: "Uncaught TypeError: Cannot read properties of undefined (reading 'init'

Time:07-06


I'm using smooth-scrollbar.js version 8.7.4.
Give it a check html file

As you can see there, I've linked the smooth-scrollbar.js and my main script file scripts.js.
I tried to initialize the Scrollbar but then I got the error message below:

error

Here is my scripts.js code that I used to initialize the Scrollbar:

js

Can anybody here help me solve this problem? Thanks!

CodePudding user response:

Simple answer, move the smooth-scrollbar.js script tag above your scripts.js script tag.

You're trying to access the scrollbar before the scrollbar has been loaded into the page.

CodePudding user response:

Your import order is wrong

Change this: enter image description here Into this: enter image description here

  • Related