Study Notes - Using the el-dropdown component in vue to report an error

At work today, I found the drop-down box made by el-select. After the drop-down menu is expanded, when the mouse clicks on the area outside the drop-down box, the drop-down menu is not closed. Then, I opened the console and found this error.

Uncaught TypeError: Cannot read properties of null (reading 'setAttribute')
    at VueComponent.removeTabindex (dropdown.js:443:1)
    at VueComponent.hide (dropdown.js:369:1)
    at Object.documentHandler (clickoutside.js:39:1)
    at clickoutside.js:25:1
    at Array.forEach (<anonymous>)
    at HTMLDocument.<anonymous> (clickoutside.js:24:1)


1. Errors

 Two, the reason

When using the "el-dropdown" component, its subcomponent "el-dropdown-menu" is not added.

The main reason is that during the code iteration process, some codes are no longer needed, but for the convenience of the moment and the need to restore the original code in the future, they have not been completely modified. So something went wrong.

The first time I encountered this error, it took about an hour to solve it.

 After the error is resolved, clicking on other areas will not report the above error again.

Of course, the drop-down box can also be collapsed after clicking other areas.

Guess you like

Origin blog.csdn.net/qq_41339126/article/details/130885923