please note, that I spend the last 2h searching through SO's similar subjects, to get to a solution, but failed. That's why I ask you now for help.
I am trying to achieve the following:
I have a scoreboard with some results, which should look like this:
- John Doe 100 pts
- John Smith 50 pts
- No Name
- No Name
- No Name
I have an array for this called scoreBoardArray.
data() {
return {
scoreBoardArray: [
{ id: '1', name: 'John Doe', pts: 100 },
{ id: '2', name: 'John Smith', pts: 50 },
],
}
},
I can loop through it, but fail to do it exactly 5 times and spit out the "No Name", when no record is found.
My code (and my attempts to solve the problem):
<ul>
<li v-for="item in scoreBoardArray" :key="item.id">
<span v-if="item.id">{{ item.name }} {{ item.pts }}</span>
<span v-if="!item.id">No Name</span
</li>
</ul>
of course, I have tried to solve the problem with the use of a computed property and a simple for(let i=0; i<6; i++) {...} loop but somehow cannot get it working.