JavaScript
x
4
1
this.$http.get(api).then(response => {
2
vm.products = response.data.products;
3
});
4
If i have data about products and i want to randomly render products what should i do?
Advertisement
Answer
You can set a computed property where you shuffle your products list, something like this:
JavaScript
1
6
1
computed {
2
shufflesProducts() {
3
return vm.products.sort(() => Math.random() - 0.5);
4
}
5
}
6