December 2017
Beginner to intermediate
376 pages
7h 53m
English
Rather than supplying a string template for your component, you can instead supply a render function. Without understanding the syntax, you can probably tell from the following example that the render function is generating a semantically equivalent template to the string template in the previous example. Both define a div with an id attribute of my-component and with inner text of My component:
Vue.component('my-component'</span>, { render(createElement) { createElement('div', {attrs:{id:'my-component'}}, 'My component'); // Equivalent to <div id="my-component">My component</div> } })
Render functions are more efficient because they don't require Vue to first compile the template string. The downside, though, is that writing ...
Read now
Unlock full access