this.$http.get(api).then(response => {
vm.products = response.data.products;
});
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:
computed {
shufflesProducts() {
return vm.products.sort(() => Math.random() - 0.5);
}
}