0

Very weird situation, when I push any number which already exists in my array it duplicates and breaks my doom element. Array keeps normal, but doom displays something like this:

enter image description here

array: enter image description here

my watcher :

  lastWins(){
      console.log(this.lastWins);
      this.lastWins.shift();
   }

Doom:

<ul class="gameHistoryList_rou">
        <li :style="{background: historyCheckColor(win)}" v-for="win of lastWins" :key="win">{{ win }}</li>
      </ul>

method to push(splice for watch):

this.lastWins.push(Math.round(Math.random() * 36));
this.lastWins = this.lastWins.splice(0);

1 Answer 1

1

You need to set an unique key for each item.

Try this:

<ul class="gameHistoryList_rou">
    <li :style="{background: historyCheckColor(win)}" v-for="(win, index) of lastWins" :key="index">{{ win }}</li>
</ul>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.