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

后端 未结 6 874
挽巷
挽巷 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:14

    When I ran into this issue I was trying to create the whole dropdown list dynamically in JS. The fix for me was creating the list and any default list elements in HTML:

    Then appending any dynamic values in JS:

    contents.forEach(function(content) {
        var buffer = "";
        var template = $(buffer);
        $(template).text(content);
        $("select1").find("select").append(template);
    });
    
    $("select").formSelect();
    

提交回复
热议问题