Materialize: Cannot set property 'tabIndex' of null at Dropdown._makeDropdownFocusable

后端 未结 6 941
挽巷
挽巷 2021-01-18 03:21

I am trying to test my vuejs component via jest that contains materialize select. When performing a component test, I get the following error in materialize.js:



        
6条回答
  •  长情又很酷
    2021-01-18 04:01

    I just stumbled this issue too while using Materializecss for my Vue project. As mentioned by sajjad, using id selector instead of class works. However, this is problem for initializing multiple dropdown, since each dropdown must have unique ID.

    The way I solve this is just by selecting all the elements with the '.dropdown-trigger' class, and initialize every each of those. It works for me.

    $.each($('.dropdown-trigger'), function(index, value) {
            $(value).dropdown();
    });
    

提交回复
热议问题