How to do it...

Let's set up the riddle in our HTML:

<div id="app">   <article>     They call me fruit.<br>     They call me fish.<br>     They call me insect.<br>     But actually I'm not one of those.     <div id="solution" @click="showSolution = true">       I am a <span id="dragon" v-show="showSolution">Dragon</span>     </div>   </article> </div>

The Vue instance is initialized very easily; you just have to write the following:

new Vue({     el: '#app',   data: {     showSolution: false   } })

In the CSS, we want to make clear that the <div> solution can be clicked on, and so we add the following rule:

#solution {   cursor: pointer; }

At this point the application works, but you will see the Dragon immediately. We want to add a touch of class to our riddle and ...

Get Vue.js 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.