JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://unpkg.com/vue"></script>
<div id="app">
<h2 v-for="item in toArray(map)">{{ item }}</h2>
<button @click="append">
Add an item
</button>
</div>
JavaScript
new Vue({
el: '#app',
data: { map: new Map(), counter: 0 },
methods: {
append() {
this.map.set(++this.counter, `some value ${this.counter}`)
// vue's reactivity doesn't know anything changed
// so we tell it manually to update
this.$forceUpdate()
},
toArray(dataSet) {
return Array.from(dataSet)
}
}
})