@jf/vue-prop-sep

2.0.0 • Public • Published

vue-prop-sep stable

npm install vue-prop-sep

Add get, has, remove and set methods to Vue componentes.

Usage

Using . as separator (by default).

import VuePropSep from 'vue-prop-sep';
import Vue        from 'vue';

Vue.use(VuePropSep);

// Vue component
export default {
    data()
    {
        return {
            a : {
                b : 1
            }
        }
    },
    created()
    {
        console.log(this.get('a.b')); // 1
        this.set('a.b', 5);
        console.log(this.get('a.b')); // 5
    }
}

Changing default separator.

import VuePropSep from 'vue-prop-sep';
import Vue        from 'vue';

Vue.use(
    VuePropSep,
    {
        separator : '/'
    }
);

// Vue component
export default {
    data()
    {
        return {
            a : {
                b : 1
            }
        }
    },
    created()
    {
        console.log(this.get('a/b')); // 1
        this.set('a/b', 5);
        console.log(this.get('a/b')); // 5
    }
}

Package Sidebar

Install

npm i @jf/vue-prop-sep

Weekly Downloads

7

Version

2.0.0

License

MIT

Unpacked Size

6.22 kB

Total Files

4

Last publish

Collaborators

  • jf