vue-nsmixin

1.1.3 • Public • Published

vue-nsmixin

This small script (namespacemixin) provides a solution to use "namespaced" methods, computed and data values.

How to use?

npm i vue-nsmixin
# or
yarn add vue-nsmixin
const NsMixin = require('vue-nsmixin');
// or
import NsMixin from 'vue-nsmixin';

Vue.use(NsMixin, {
  useFn: true // use namespace function for methods
  seperator: '', // default "__"
  firstLetterUpperCase: false // set first letter of method, data or computed to uppercase
});

Now you can do this:

Vue.nsMixin('namespace', {
  // ...options
  data() {
    return {
      value: ''
    }
  },
  computed: {
    cpValue() {
      // ...
    }
  }
  methods: {
    func() {
      // ...
    }
  }
});

In your component:

this.namespace().func(); // to use this set useFn: true in options

// or

this.namespace__func(); // method

this.namespace__value; // data
this.namespace__cpValue; // computed

Readme

Keywords

none

Package Sidebar

Install

npm i vue-nsmixin

Weekly Downloads

1

Version

1.1.3

License

MIT

Unpacked Size

4.01 kB

Total Files

4

Last publish

Collaborators

  • phlp