I have successfully implemented a filters section using vue.js to display dynamic responses based on user-selected filters. The components, in this case, represent cars with attributes such as price and brand.
Now, I want to add two more filters that will allow me to sort the cars by a specific field, such as price. I have read that it is easy to sort lists by specifying a field and order...
Could someone guide me on how to create this sortable list for the cars?
Here is a simple fiddle I created, where I would like to sort the cars by price when the filter is clicked.
var Car = Vue.extend({
template: '#template_box_car',
props: {
show: {
default: true
},
code: {
default: ""
},
prize: {
default: 0
},
description: {
default: "No comment"
}
}
});
//register component
Vue.component('box_car',Car);
//create a root instance
var vm = new Vue({
el: 'body',
methods: {
sortBy: function(field, order){
}
}
});