vue-nsmixin
v1.1.3
Published
This small script (**n**ame**s**pacemixin) provides a solution to use "namespaced" methods, computed and data values.
Downloads
12
Readme
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