November 2017
Beginner to intermediate
398 pages
8h 42m
English
We have seen how to create plugins, but there is another way to improve our code--what if we could reuse component definitions such as computed properties, methods, or watchers across multiple components? This is what mixins are for!
A mixin is a component definition object that can be applied to other definition objects (including other mixins). It is very simple to write, because it looks exactly the same as a regular component definition!
Our objective here is to have a RemoteData mixin that will allow any component to make requests to the server in order to fetch data. Let's add a new mixins folder in the src directory, and create a new RemoteData.js file:
Read now
Unlock full access