vuejs

Accessing the DOM in Vue.js with $refs

April 23, 2017 by
Part 40 of 55 in the Vue.js: From Beginner to Professional series

It’s time to take a closer look at a few more special Vue instance properties and methods, with the first one being the $refs property. But before diving into the JavaScript part of things, let’s start by taking a look at the template. <div id=”app”> <h1>{{ message }}</h1> <button @click=”clickedButton”>Click Me!</button> </div> var vm =… read more

Using multiple Vue instances on the same page

April 18, 2017 by
Part 34 of 55 in the Vue.js: From Beginner to Professional series

We have created a lot of Vue instances in this course so far, but did you ever wonder if you could use multiple Vue instances on the same page? Indeed you can, as you can probably tell based on the below example. <div id="vm1"> <h1>{{ name }}</h1> </div> <div id="vm2"> <button @click="showName">Show name</button> </div> var… read more

Accessing a Vue instance outside of its declaration

April 18, 2017 by
Part 33 of 55 in the Vue.js: From Beginner to Professional series

Until now, we have done all of our work within the Vue instances themselves. But we can also reference these Vue instances by storing them in variables. I have prepared a super simple example which just displays a data property. <div id="vm1"> <h1>{{ name }}</h1> </div> new Vue({ el: '#vm1', data: { name: 'Vue Instance… read more