question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support more collection data types in v-for

See original GitHub issue

At some situations, plain object isn’t the best choise. I tried to render a Map object by v-for, but seems Vue does not support it currently. (Here’s a post I created in the Help thread on the forum.)

Hope Vue can provide the for ... of syntax in v-for to iterate over data types like Map and Set.

For example:

const map = new Map();
map.set('key1', 'val1');
map.set('key2', 'val2');

and we can render map in this way:

<ul>
    <li v-for="[key, val] of map">{{key}} - {{val}}</li>
</ul>

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:255
  • Comments:47 (6 by maintainers)

github_iconTop GitHub Comments

132reactions
catsclawcommented, Sep 7, 2016

It’s important to be able to iterate over iterators in loops. That seems plainly obvious. It’s a fundamental feature of the language.

The reasons for supporting it are:

  1. Iterators, Maps, and Sets are all valid ES6. Refusing to support them means limiting yourself to ES5, which is a decision becoming less and less justified over time.
  2. I’m building an application that has internal data stored in Maps and Sets. Instead of making them available to the UI, I now need to keep the data synced between the two manually, or write boilerplate and import it into my templates to do the conversion whenever the data is needed. This is exactly what Vue is intended to avoid.
86reactions
posvacommented, Oct 11, 2017

People wanting to use a feature is not, only by itself, an argument that can justify the need of having such feature, it’s necessary to weigh the cost and benefits (what problem is being solved) of adding such feature

Read more comments on GitHub >

github_iconTop Results From Across the Web

5 Support for Collection Data Types - Oracle Help Center
Oracle supports the varray and nested table collection data types. A varray is an ordered collection of elements. A nested table can have...
Read more >
Collection Data Types in Python - Medium
Python has 4 built-in data structures that can be used to hold a collection of objects, they are list, tuple, set, and dictionary....
Read more >
Data Type Summary - Visual Basic | Microsoft Learn
The following table shows the Visual Basic data types, their supporting common language runtime types, their nominal storage allocation, ...
Read more >
What Are Data Types and Why Are They Important? - Amplitude
Learn about common data types—booleans, integers, strings, and more—and their importance in the context of gathering data.
Read more >
JavaScript data types and data structures - MDN Web Docs
Check the typed array page for more information. Typed arrays are often used in conjunction with ArrayBuffer and DataView . Keyed collections: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found