Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question