I want to add some transition effect to a newly created item on VueJS. As in the following code, if I create a new list item using an input field, I want it to appear using the "fade" or "slide-in" effect. I could not understand this from the official documentation. How can i do this?
var vm = new Vue({ el: "#vue-instance", data: { newelement: '', list: [] }, methods: { addelement: function() { this.list.push(this.newelement); this.newelement = ''; } } });
<div id="vue-instance"> <input type="text" v-model="newelement" @keyup.enter="addelement"> <ul v-for="element in list"> <li>{{ element }}</li> </ul> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.16/vue.js"></script>
According to the official docs, you need to add an attribute transitionto your element. For instance:
transition
<div v-for="item in list" transition="someEffect">
And add some css classes with transition name:
<style> .someEffect-transition { transition: all .3s ease; height: 30px; padding: 10px; background-color: #eee; overflow: hidden; } /* .*-enter defines the starting state for entering */ /* .*-leave defines the ending state for leaving */ .someEffect-enter, .someEffect-leave { height: 0; padding: 0 10px; opacity: 0; }
v-for . https://github.com/vuejs/vue-animated-list
v-for
docs: "expand":
http://jsbin.com/kejulozoco/edit?html,output
https://vuejs.org/guide/transitions.html
Source: https://habr.com/ru/post/1650904/More articles:Database locked while updating data in background - sqliteSelect all columns, but group only one element in linq - c #Strong Validation Test PHPUnit assertEquals - assertionsWhat is the best way to implement roles and permissions in Express REST Api - reststd :: bind assigned to std :: function - c ++Laravel - Validation - required if field is null - phphttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1650906/add-tax-free-fees-to-woocommerce-cart-programmatically&usg=ALkJrhi77Rcobo7_xv58jU1kMAHAMRZB6gStrength div in left column - htmlCommunication debug warning "character type does not match the original declaration" - cHow to use a parameter from the list of objects based on another parameter? (Javascript) - javascriptAll Articles