H
H
hannyto11112021-06-05 20:38:49
Vue.js
hannyto1111, 2021-06-05 20:38:49

Why is v-for not removed when using map?

Hello, this code removes an element from the map when the element is clicked, but why is the removal of the element in the dom not happening

<!DOCTYPE html>
<header>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
</header>

<body>
  <div id="app">
    <div v-for="mapKey in messages.keys()" :key="mapKey">
      <div @click="deleteFromMap(messages, mapKey)">
        {{ messages.get(mapKey) }}
      </div>
    </div>
  </div>
</body>

<script>
  new Vue({
    el: "#app",
    data: {
      messages: new Map(),
    },
    methods: {
      deleteFromMap(map, key) {
        map.delete(key);
      },
    },
    created() {
      this.messages.set(0, "string");
    },
  })

</script>

</html>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2021-06-05
@hannyto1111

Why should it be animated? What did you do for this?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question