https://github.com/vicompany/vue-mixin-data-attributes
Reads `data-` attributes from the element and assigns them to the Vue instance/component.
https://github.com/vicompany/vue-mixin-data-attributes
Last synced: about 2 months ago
JSON representation
Reads `data-` attributes from the element and assigns them to the Vue instance/component.
- Host: GitHub
- URL: https://github.com/vicompany/vue-mixin-data-attributes
- Owner: vicompany
- License: mit
- Created: 2017-02-16T08:09:13.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-16T10:16:31.000Z (over 9 years ago)
- Last Synced: 2025-01-03T18:15:25.738Z (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-mixin-data-attributes
Reads `data-` attributes from the element and assigns them to the Vue instance/component.
You can use the mixin on components and as global mixin. See [mixin documentation](https://vuejs.org/v2/guide/mixins.html).
```html
```
```js
import dataAttributes from 'vue-mixin-data-attributes';
Vue.component('my-message', {
mixins: [dataAttributes],
data: () => {
return {
message: 'Default message',
},
},
mounted() {
console.log(this.message); // Logs: This is OK
}
});
```
## Installation
`npm install vue-mixin-data-attributes`