vue-mixin-data-attributes

1.0.3 • Public • Published

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.

<my-message data-message="This is OK"></my-message>
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

Package Sidebar

Install

npm i vue-mixin-data-attributes

Weekly Downloads

1

Version

1.0.3

License

MIT

Last publish

Collaborators

  • vicompany-frontend
  • edw1n
  • svensigmond
  • timseverien
  • vi-company
  • sjorsjes