jeudi 31 janvier 2019

Produce Random Numbers in Laravel with Vue.js

I'm new in Vue.js and I'm having a hard time producing random numbers. In my Vue file, I have this piece of code under script:

var numeral = require("numeral");
Vue.filter("formatNumber", function(value)
{
    return numeral(value).format("0,0");
});

...calling the method:

getRandomNum()
    {
        this.like = Math.random() * 100;
        this.rate = Math.random() * 10;
        this.comment = Math.random() * 100;
    }

works like a charm that produces the number of likes, ratings and comments in my html:

enter image description here

However, if you'd notice, even though they're random in a sense whenever I refresh my DOM, technically they're still all the same in each rows. My question is, is there a way that I can produce a whole totally different random numbers in each row? Thanks! Please respect, I'm new to Vue.js.




Aucun commentaire:

Enregistrer un commentaire