I'm trying to get a random number when cliking a button and I'm doing something wrong, it works with another example that doesn't have a function so I must be doing something wrong but can't find what. Right now it prints the function code as text.
This is the html:
<div id="aleatori">
<button v-on:click="randomNumber">Aleatori</button>
<p></p>
</div>
This is the js
var aleatori = new Vue({
el:'#aleatori',
data: {
randomNumber: function () {
this.random = Math.floor(Math.random() * (10 - 1 + 1)) + 1
}
}
})
Aucun commentaire:
Enregistrer un commentaire