-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Question: How to iterate over maps and sets with v-for #6644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Maps and sets are not currently supported in v-for, heard it will be possible in Vue 3.0 |
It's currently not supported in core (there's no reactivity detection for these data structures). But you can use |
@yyx990803 @sqal |
Thanks |
For those coming from google, this is not supported, nor is it planned to be. Please see this issue: #2410 |
if not |
Sometimes you don't want reactivity, you just want to iterate over static data keyed by types other than string. It would be nice if |
This is still a top-ranked result for google searches on iterating a Map with v-for, so for those landing here as I did, in Vue 3 (vue-next as of this writing), reactivity on Map (and Set) is supported. And you can conveniently write a v-for loop using array destructuring syntax:
|
Thank you, you saved my day. |
Using a Map should solve the ugly problem of not having a standard-defined enumeration order for the keys of an Object |
I needed to also have a key, like (in Vue3)
|
Apparently you can also use <div v-for="[fooKey, barValue] of fooBarMap" > |
What problem does this feature solve?
How to iterate over Map and Set with
v-for
? I want to use the key/index field or both.(ES6 Map/Set)What does the proposed API look like?
N/A
The text was updated successfully, but these errors were encountered: