Skip to content

Tag: vuejs2

How to animate list items in Vue when one is removed

i have a vertical list of items, each of which can be removed. I put my items inside a transition-group and created simple opacity and transform transitions for them. The transitions on the removed elements work as expected, however if I remove an element which is not placed at the bottom, the ones beneath ju…

How to tell if a Vue component is active or not

I have a Vue component that is wrapped in a <keep-alive> tag to prevent re-rendering. Within the component, I want to react to some change in global data by firing a method. But, I only want to fire the method if the component is currently active. Right now, I’m doing something like this: But I wa…

Detecting keyboard button and play sound in vue.js

The code below actually plays sounds on each button click with vue.js. How is it possible to detect keyboard press and play sound when DOM is ready and not when the buttons are clicked? for example on enter play sound v-on:keyup.13=”playSound(‘path/to/mp3’)” Vue documentation mostly ex…

How to emit an event from Vue.js Functional component?

As the title of the question, this context is not available in the functional component. So if I have to emit an event, how can I do that? For example in below code snippet: My functional component doesn’t have this context and hence $emit is not available. How can I bubble-up this event? Answer This is…

Getting first element of Observer Array

Hi dear friends, i cannot get first element or data etc. I did try notes[0] but the result was ‘undefined’. What kind of array is this? First time i’ve seen and i am using Vue.Js Answer You can access the first element simply using Array.from: Also, {__ob__: Observer} is a special property a…