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.

v-for iterating over v-else

See original GitHub issue

Version

2.5.17

Reproduction link

https://jsfiddle.net/hirokiosame/7mfcktv4/

Steps to reproduce

Add a v-for and v-if to an element with a v-else sibling. If the v-if condition evaluates to be falsy, the iteration happens over the v-else element.

What is expected?

For the v-for to not iterate over the v-else

What is actually happening?

The v-for is iterating over the v-else

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
privatenumbercommented, Sep 22, 2018

To be clear, the bug I’m reporting isn’t that v-for is happening before v-if. It’s that the v-for is being applied to code outside of the iteration.

What’s happening:

<template v-for="i in 10">
	<div v-if="useDiv">
		Div: {{ i }}
	</div>
	<span v-else>
		Span
	</span>
</template>

Expected behavior:

<template v-for="i in 10">
	<div v-if="useDiv">
		Div: {{ i }}
	</div>
</template>
<span v-else>
	Span
</span>
Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Iterate Over Items in Vue.js With V-for
We can loop over the items in a shoppingItems array from the data model. This can be accomplished by adding the v-for directive...
Read more >
How to Iterate Through a Dictionary in Python
In this step-by-step tutorial, you'll take a deep dive into how to iterate through a dictionary in Python. Dictionaries are a fundamental data...
Read more >
How to Write Better Vue v-for Loops
v-for is most commonly used to render items in a list, but can also be used to iterate over an object's properties or...
Read more >
Iterate over a dictionary in Python
Iterate over a dictionary in Python · Access key using the build .keys() · Access key without using a key() · Iterate through...
Read more >
Looping through Object Properties in Vue
This outputs a list with both the object keys and their corresponding values. You might be wondering why the second alias is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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