https://github.com/ph1p/vue-nsmixin
Vue namespaced mixins
https://github.com/ph1p/vue-nsmixin
Last synced: over 1 year ago
JSON representation
Vue namespaced mixins
- Host: GitHub
- URL: https://github.com/ph1p/vue-nsmixin
- Owner: ph1p
- License: mit
- Created: 2019-04-05T12:32:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-06T10:52:41.000Z (over 7 years ago)
- Last Synced: 2025-03-30T06:34:27.466Z (over 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## vue-nsmixin
This small script (**n**ame**s**pacemixin) provides a solution to use "namespaced" methods, computed and data values.
## How to use?
```bash
npm i vue-nsmixin
# or
yarn add vue-nsmixin
```
```javascript
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:
```javascript
Vue.nsMixin('namespace', {
// ...options
data() {
return {
value: ''
}
},
computed: {
cpValue() {
// ...
}
}
methods: {
func() {
// ...
}
}
});
```
In your component:
```javascript
this.namespace().func(); // to use this set useFn: true in options
// or
this.namespace__func(); // method
this.namespace__value; // data
this.namespace__cpValue; // computed
```