1.0.0 • Published 7 years ago

vue-orderby-mixin v1.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

vue-orderBy mixin

Sort a array object with a custom field

Install

$ npm install vue-orderby-mixin

Usage

this.orderBy(obj, column, type)

	obj => Array object
	column => A custom field for sorting
	type => ASC or DESC
    

Example

import orderBy from 'vue-orderby-mixin'
	export default {
		data () {
	    	return {
	    		users: [
        	  		{ id: 1, name: 'John' },
        	  		{ id: 2, name: 'Jane' }
        		],
	    	}
	    },
		mixins: { orderBy },
		methods: {
			example () {
				this.orderBy(this.users, 'name', 'ASC')
			}
		}
	}

Result

idname
2Jane
1John