Element-ui will report an error Cannot read property 'forEach' of null no matter where it is clicked.

Click anywhere on the page and you will report an error
clipboard.png

element-ui

clipboard.png


I've encountered it, too. Here's my problem:

<el-col :span="14" class="userinfo">
    <el-dropdown trigger="hover">
        <span class="el-dropdown-link userinfo-inner" @click="logout"></span>
    </el-dropdown>
</el-col>

when I use the el-dropdown tag, I don't use el-dropdown-menu or even el-dropdown-item. Maybe it's because the page traverses the drop-down menu every time, but I don't write down the pull-down menu, so no matter what I do, I will declare forEach as null,. I just get rid of el-dropdown. I'm a beginner, and there are many holes, so I specifically register the reply in order to reply so that I can retrieve it later

.
<el-col :span="14" class="userinfo">
    <span class="el-dropdown-link userinfo-inner" @click="logout"></span>
</el-col>

generally this problem is caused by the fact that the variable in forEach is not an array.
output that variable in front of forEach and then debugger, to see what it is.
usually when I deal with forEach, I will judge

.
arr && arr.forEach(i => {});

// 
(arr || []).forEach(i => {});

The variable

this.menuItemsArray is not an array, but null

.

maybe there is something wrong with your assignment


the default value of menuItemsArray is null.

querySelectorAll to an array should not be null


has it been solved? what's the reason? I also encountered this problem in the project


Hello. Have I also encountered a solution?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31835-2bda8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31835-2bda8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?