How to iterate over Map and Set with v-for
? I want to use the key/index field or both.(ES6 Map/Set)
<mt-index-list>
<mt-index-section v-for="(list, key) in serverData.indexMap" :index="key" :key="key">
<mt-cell title="Aaron"></mt-cell>
</mt-index-section>
</mt-index-list>
N/A
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 (list, key) in Array.from(map)
+ $forceUpdate()
to simulate it.
@yyx990803 @sqal
OK, I got it. Thanks for your reply.
Thanks
For those coming from google, this is not supported, nor is it planned to be.
Please see this issue: https://github.com/vuejs/vue/issues/2410
if not v-for
then is there any other way to iterate over map in vuejs?
Most helpful comment
It's currently not supported in core (there's no reactivity detection for these data structures). But you can use
(list, key) in Array.from(map)
+$forceUpdate()
to simulate it.