How do we loop over a variable of type Record<string, string[]>
in Vue? My variable contains a key-value dictionary that looks like this:
errors = {
'username': ['Must contain at least 1 special character', 'Min length is 6'],
'password': ['Required']
}
I tried this but Vue (or TS or ESLint, not sure) is not happy:
<ul>
<li v-for="e in errors" :key="e">
{{ e }}
<ul>
<li v-for="e2 in e" :key="e2">
{{ e2 }}
</li>
</ul>
</li>
</ul>
It shows this error for the first :key
above:
`Type 'string[]' is not assignable to type 'string | number | symbol | undefined'
BTW, I'm using Vue 3 with TS. errors
is part of an interface and is defined as Record<string, string[]>
.