npm

Need private packages and team management tools?Check out npm Orgs. »

vue-orderby-mixin

1.0.0 • Public • Published

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

id name
2 Jane
1 John

install

npm i vue-orderby-mixin

Downloadsweekly downloads

4

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability