Topic: Importing MDB on the app.js not working

Salekur Rahaman free asked 2 years ago


I'm using MDB free version.But import * as mdb from 'mdb-ui-kit'; not properly working.

After importing the MDB js library or module, my entire js code not working. Also, it gives me the error given below:

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.
    at v._getHeight (mdb-ui-kit.js?v=919936fe:1879:31)
    at v._saveInitialHeights (mdb-ui-kit.js?v=919936fe:1883:107)
    at v._init (mdb-ui-kit.js?v=919936fe:1846:52)
    at new v (mdb-ui-kit.js?v=919936fe:1808:98)
    at mdb-ui-kit.js?v=919936fe:1894:29
    at Array.forEach (<anonymous>)
    at Module.n (mdb-ui-kit.js?v=919936fe:1892:37)
    at o (mdb-ui-kit.js?v=919936fe:4427:75)
    at mdb-ui-kit.js?v=919936fe:4424:20
    at mdb-ui-kit.js?v=919936fe:9:82

Note that, I'm using the MDB node package on Laravel (v9.26.1)


Grzegorz Bujański staff answered 2 years ago


How do you import MDB? I created a project from scratch and I don't see this error. My configuration looks like this:

app.js

import './bootstrap';
import * as mdb from 'mdb-ui-kit'; // lib
import 'mdb-ui-kit/css/mdb.min.css';

welcome.blade.php

welcome.blade.php
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        ...
        @vite('resources/js/app.js')
    </head>
    <body class="antialiased">
      ...
    </body>
</html>


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 5.0.0
  • Device: Windows 11
  • Browser: Google Chrome (v104.0.5112.102)
  • OS: Windows 11 (64)
  • Provided sample code: No
  • Provided link: No