Chapter 9. Extending Vue
This chapter covers
- Learning about mixins
- Understanding custom directives
- Using the render function
- Implementing JSX
In the previous chapter we discussed transitions and animations. In this chapter we’ll look at different ways we can reuse code in Vue.js. This is important because it allows us to extend the functionality of our Vue.js applications and make them more robust.
We’ll begin by looking at mixins. Mixins are a way to share information between components; functionality is essentially “mixed” into the component. They’re objects that have the same methods and properties that you’d see in any Vue.js component. Next, we’ll look at custom directives. Custom directives allow us to register our own directives, which we can use to create whatever functionality we want. Then we’ll look at the render function. With the render function we can go beyond using normal templates and create our own using JavaScript. Last, we’ll look at using the render function with JSX, which is an XML-like syntax for JavaScript.