November 2017
Beginner to intermediate
398 pages
8h 42m
English
The main advantages of writing render functions directly are that they are closer to compiler and you have the full power of JavaScript available to manipulate the template. The obvious drawback is that it doesn't look like HTML anymore, but this can be alleviated by JSX as we will see in the What is JSX section.
For example, you could create a component that renders a title at any level we want:
Vue.component('my-title', { props: ['level'], render (h) { return h( // Tag name `h${this.level}`, // Default slot content this.$slots.default, ) }})
And then, for example, we would use it in our template to render an <h2> ...
Read now
Unlock full access