Created
April 20, 2020 07:26
-
-
Save ilonacodes/76a967babbd5d96915ae17bf3e40f777 to your computer and use it in GitHub Desktop.
index.js | Vue.js implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | Vue.js implementation | |
const app = new Vue({ | |
el: '#app', | |
data: { | |
dices: [ | |
{ dots: 1 }, | |
{ dots: 1 }, | |
] | |
}, | |
mounted() { | |
// first initial roll for when the component mounts | |
this.roll(); | |
}, | |
methods: { | |
roll() { | |
this.dices.forEach(dice => { | |
dice.dots = Math.floor(Math.random() * 6) + 1; | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment