Skip to content

Instantly share code, notes, and snippets.

@ilonacodes
Created April 20, 2020 07:26
Show Gist options
  • Save ilonacodes/76a967babbd5d96915ae17bf3e40f777 to your computer and use it in GitHub Desktop.
Save ilonacodes/76a967babbd5d96915ae17bf3e40f777 to your computer and use it in GitHub Desktop.
index.js | Vue.js implementation
// 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