Complete Vue.js 2 Web Development_ Practical guide to building end-to-end web development solutions with Vue.js 2

(singke) #1
Advanced Vue.js - Directives, Plugins, and Render Functions Chapter 17

How to do it...


You will build a page for a plumber club. The page will look like this:


Whenever we write a name inside the name textbox, it will be written in the greeting


exactly like the v-model directive.


For this recipe, we are starting from the end instead of the beginning because usually when


you have to resort to the render function, you have a pretty clear idea of what you are


trying to get.


In the HTML side of our app, let's start with an empty tag:


<div id="app"></div>

In the JavaScript, write an empty

element in the render function:


new Vue({
el: '#app',
render: h => h('div')
})

The first thing we'll put inside is the title, like so:


new Vue({
el: '#app',
render: h => h(
'div',
[
h('h1', 'The plumber club page')
]
)
})
Free download pdf