Skip to content

for (const tag of tags) 报错 #1

Open

Description

@laqudee

在src/layout/components/TagsView/index.vue中,line 115,运行报错,使用for of 遍历对象,出错...
Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a Symbol.iterator method.

我的解决方案:

for (const index of Object.keys(tags)) {
          // console.log(tags[index]);
          let tag = tags[index]
          console.log('tag: ', tag);
          if (!tag) return
          if (tag.path === this.$route.path) {
            this.$refs.scrollPane.moveToTarget(tag)
            // when query is different then update
            if (tag.fullPath !== this.$route.fullPath) {
              this.$store.dispatch('tagsView/updateVisitedView', this.$route)
            }
            
          }
        }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions