© Brett Nelson 2018
Brett NelsonGetting to Know Vue.jshttps://doi.org/10.1007/978-1-4842-3781-6_9

9. Reusable Code

Brett Nelson1 
(1)
Eagan, Minnesota, USA
 

Components are great for reusing an entire custom element, but we can’t use just a portion of the component. To share functionality among multiple components, we have to use mixins. Custom directives will allow us to build out functionality that we can apply to standard HTML components and custom Vue.js components. The render function will give us more control over how our template is built, giving us the ability to use logic in JavaScript to build our templates.

Mixins

Mixins allow us to create “base” components with common functionality that we want to share with multiple components. This can ...

Get Getting to Know Vue.js: Learn to Build Single Page Applications in Vue from Scratch now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.