13). VueJS – Mixins
Basics Mixins are a flexible way to reusable functionalities for Vue components. A mixin object can contain any component options. When a component uses a mixin, all options in the mixin will be “mixed” into the component’s own options. JS Fiddler here for Basic Mixin var mixin = { data: function ( ) { return { message: 'hello' , foo: 'abc' } } } new Vue({ mixins: [mixin], data: function ( ) { return { message: 'goodbye' , bar: 'def' } }, created: function ( ) { console .log( this .$data) // => { message: "goodbye", foo: "abc", bar: "def" } } }) Option Merging When a mixin and a component contain overlapping options, they are merged as shown in the following example. JS Fiddler here for option Merging Global Mixin You can also apply a mixin globally. Use with caution! Once you apply a mixin globall...