Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="app">
- <input type="number" placeholder="enter a number" v-model="n">
- <button type="button" @click.prevent="addToSet()">Add to Set</button>
- </div>
- new Vue({
- el: "#app",
- data: {
- n: null,
- nSet: new Set()
- },
- methods: {
- addToSet: function() {
- this.nSet.add(this.n);
- console.log(this.n + ' added to Set');
- }
- },
- watch: {
- nSet: function (newVal, oldVal) {
- console.log(newVal);
- }
- }
- });
Add Comment
Please, Sign In to add comment