Filter is used in vue and indexOf is used to report errors.

whether I abbreviate it or write it step by step, it is an error. There is no corresponding array filtered out. Item.username is a string and can be printed out, not without value. Why the report was wrong. Please point out if there is anything wrong, thank you!

Jun.13,2022

first determine whether item.username exists or whether it is a string, and then use indexOf


has already been printed. When reporting an error, item.username is undefined


you see if there is a username field in the fifth object of your array mailsit, and if so, see if it is any [] or string type. I feel that there should be no such field


.

found the problem. It's return. It's not return. I'd better go to the code. This field is available, and the undefined error is also correct. Because there is a field in the array, username does not have a value, so report undefined.

let usd = this.maillsit.filter (item = > {

)
            if (item.username) {
              if (item.username.indexOf(this.sermsg) != -1) {
                return item
              }
            }
          })
          this.serlist = usd
          
          

you need to return item out. The return above are true and false

.
Menu